行 16: SqlCommend myComm = new SqlCommend(strInsert, sqlcon);
这个?
继续向前-------------------努力成为高手
void page_load(object serder,EventArgs e)
{
SqlConnection sqlcon=new SqlConnection("Data Source=127.0.0.1;uid=sa;pwd=;Initial Catalog=chapter");
DataSet ds=new DataSet();
sqlcon.Open();
string strInsert = "insert into tabstudent(studentid, name, age, address) values('97070705', 'huang', 30, 'bejing')";
SqlCommand myComm = new SqlCommand(strInsert, sqlcon);
myComm.ExecuteNonQuery();
ds.Tables["tabstudent"].AcceptChanges();
dg.DataSource=ds.Tables["tabstudent"].DefaultView;
dg.DataBind();
myComm = null;
sqlcon.Close();
sqlcon=null;
labContent.Text+="添加记录成功";
}
这样写是不是还少了点什么呢,提示tabstudent无效
[此贴子已经被作者于2007-4-20 20:30:23编辑过]