FreeTextBox连入数据库的问题!
从http://www.shaiit.com/ASPNET/AspNetshili/3012.html网址学到!
可是用他那方法出现了许多错误!!!一时解决不了!麻烦大家帮忙!!!
数据库:表名:newtb
字段:ID content time (附:数据库里什么也没有加!想从FreeTextBox里加入)
FreeTextBox页面代码:
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using FreeTextBoxControls;using FreeTextBoxControls.Design;using FreeTextBoxControls.Common;using System.Data.SqlClient;using System.Data.Common;public partial class _Default : System.Web.UI.Page{ private void Page_Load(object sender, EventArgs e) { //put user code to initialize the page here if (!IsPostBack) { SqlConnection myConn = new SqlConnection("server=(local);datdabase=newtb;uid=sa;pwd=123"); SqlCommand myCmd = new SqlCommand("select * from test where id=2", myConn); myConn.Open(); SqlDataReder myDr; myDr = myCmd.ExecuteReader(); myDr.Read(); Response.Write(myDr["content"].ToString()); myDr.Close(); myConn.Close(); } } private void Button1_Click(object sender, EventArgs e) { SqlConnection myConn = new SqlConnection("server=(local);database=newtb;uid=sa;pwd=123"); SqlCommand myCmd = new SqlCommand("insert into test (content) values('" + FreeTextBox1.Text + "')", myConn); myConn.Open(); myCmd.ExecuteNonQuery(); myConn.Close(); }}