日期:2014-05-16 浏览次数:20385 次
数据写不进数据库:
using System;
using System.Data;
using System.Configuration;
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 System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
// myConnection.Open();
if (!Page.IsValid)
{
string conn = "server=741FC6DFB4214A2;database=pingou;user id=sa;password=sa ";
SqlConnection myConnection = new SqlConnection(conn);
string sql = "select * from tbTree where ID = '+this.TextBox1.Text+ ' ";
SqlCommand myCommand = new SqlCommand(sql, myConnection);
myConnection.Open();
SqlDataReader myDataReader = myCommand.ExecuteReader();
DataTable dt= new DataTable();
dt.Columns.Add(new DataColumn( "ID ",typeof(string)));
dt.Columns.Add(new DataColumn( "Name ",typeof(string)));