下面的代码,怎么没有把我数据插入到数据库(其中Insert_teacher是在数据库里写好的insert into插入存储过程)
................................................
................................................
..........
string str = ConfigurationManager.ConnectionStrings["CourseConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(str);
conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select * from teacher", conn);
da.Fill(ds, "teacher");
da.InsertCommand = new SqlCommand("Insert_teacher", conn);
da.InsertCommand.CommandType = CommandType.StoredProcedure; da.InsertCommand.Parameters.Add(new SqlParameter("@tid", SqlDbType.Char, 10));
da.InsertCommand.Parameters["@tid"].Value = teacherNumber.Text.Trim(); da.InsertCommand.Parameters.Add(new SqlParameter("@tname", SqlDbType.VarChar, 50));
da.InsertCommand.Parameters["@tname"].Value = teacherName.Text.Trim(); da.InsertCommand.Parameters.Add(new SqlParameter("@tpwd", SqlDbType.VarChar, 50));
da.InsertCommand.Parameters["@tpwd"].Value = teacherPwd.Text.Trim(); da.InsertCommand.Parameters.Add(new SqlParameter("@tpost", SqlDbType.Char, 10));
da.InsertCommand.Parameters["@tpost"].Value = teacherPost.Text.Trim();
da.Update(ds, "teacher");
conn.Close();
Response.Redirect("ManageList.aspx"); ................
...............
................................................
................................................
..........
string str = ConfigurationManager.ConnectionStrings["CourseConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(str);
conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select * from teacher", conn);
da.Fill(ds, "teacher");
da.InsertCommand = new SqlCommand("Insert_teacher", conn);
da.InsertCommand.CommandType = CommandType.StoredProcedure; da.InsertCommand.Parameters.Add(new SqlParameter("@tid", SqlDbType.Char, 10));
da.InsertCommand.Parameters["@tid"].Value = teacherNumber.Text.Trim(); da.InsertCommand.Parameters.Add(new SqlParameter("@tname", SqlDbType.VarChar, 50));
da.InsertCommand.Parameters["@tname"].Value = teacherName.Text.Trim(); da.InsertCommand.Parameters.Add(new SqlParameter("@tpwd", SqlDbType.VarChar, 50));
da.InsertCommand.Parameters["@tpwd"].Value = teacherPwd.Text.Trim(); da.InsertCommand.Parameters.Add(new SqlParameter("@tpost", SqlDbType.Char, 10));
da.InsertCommand.Parameters["@tpost"].Value = teacherPost.Text.Trim();
da.Update(ds, "teacher");
conn.Close();
Response.Redirect("ManageList.aspx"); ................
...............
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货