各位大侠帮帮忙啊!!!!
……
case "Insert":
TextBox TextBoxage = new TextBox();
TextBox TextBoxadds = new TextBox();
TextBox TextBoxname = new TextBox();
TextBox TextBoxwrk = new TextBox();
TextBox TextBoxsex = new TextBox(); try
{
myCommand.CommandText = "insert into memberInfo(姓名,性别,地址,年龄,职位)values(@xm,@xb,@dz,@nl,@zw)";
myCommand.Parameters.Add("@xm", SqlDbType.Char, 20, "姓名");
myCommand.Parameters.Add("@xb", SqlDbType.Char, 10, "性别");
myCommand.Parameters.Add("@dz", SqlDbType.Char, 500, "地址");
myCommand.Parameters.Add("@nl", SqlDbType.Char, 20, "年龄");
myCommand.Parameters.Add("@zw", SqlDbType.Char, 20, "职位");
myCommand.Parameters["@xm"].Value = TextBoxname.Text;
myCommand.Parameters["@xb"].Value = TextBoxsex.Text;
myCommand.Parameters["@dz"].Value = TextBoxadds.Text;
myCommand.Parameters["@nl"].Value = TextBoxage.Text;
myCommand.Parameters["@zw"].Value = TextBoxwrk.Text;
myConnection.Open();
myCommand.ExecuteNonQuery();
Response.Write("<script>alert('添加成功!')</script>");
myConnection.Close();
MyDataBind();
} finally
{
myConnection.Close();
}
break;
……
我用insert语句写入数据库时,在数据库中查看到成功插入了一条空的数据,请求大侠们帮我解决啊!数据写不进数据库怎么办? 能帮改代码最好!!!
……
case "Insert":
TextBox TextBoxage = new TextBox();
TextBox TextBoxadds = new TextBox();
TextBox TextBoxname = new TextBox();
TextBox TextBoxwrk = new TextBox();
TextBox TextBoxsex = new TextBox(); try
{
myCommand.CommandText = "insert into memberInfo(姓名,性别,地址,年龄,职位)values(@xm,@xb,@dz,@nl,@zw)";
myCommand.Parameters.Add("@xm", SqlDbType.Char, 20, "姓名");
myCommand.Parameters.Add("@xb", SqlDbType.Char, 10, "性别");
myCommand.Parameters.Add("@dz", SqlDbType.Char, 500, "地址");
myCommand.Parameters.Add("@nl", SqlDbType.Char, 20, "年龄");
myCommand.Parameters.Add("@zw", SqlDbType.Char, 20, "职位");
myCommand.Parameters["@xm"].Value = TextBoxname.Text;
myCommand.Parameters["@xb"].Value = TextBoxsex.Text;
myCommand.Parameters["@dz"].Value = TextBoxadds.Text;
myCommand.Parameters["@nl"].Value = TextBoxage.Text;
myCommand.Parameters["@zw"].Value = TextBoxwrk.Text;
myConnection.Open();
myCommand.ExecuteNonQuery();
Response.Write("<script>alert('添加成功!')</script>");
myConnection.Close();
MyDataBind();
} finally
{
myConnection.Close();
}
break;
……
我用insert语句写入数据库时,在数据库中查看到成功插入了一条空的数据,请求大侠们帮我解决啊!数据写不进数据库怎么办? 能帮改代码最好!!!
类型不对?
mysql是?
oracel是:把所有的@全改了吧
TextBox TextBoxadds = new TextBox();
TextBox TextBoxname = new TextBox();
TextBox TextBoxwrk = new TextBox();
TextBox TextBoxsex = new TextBox();这个就写在try上面?还是为了说明TextBoxage....才写上的?在myConnection.Open();处断点,运行到这里时,看看那几个textbox的text有没有值。