string constr = ConfigurationManager.ConnectionStrings["jmc"].ConnectionString;//下面使用MySql Connector/net提供的专用对象MySqlConnection mycon = new MySqlConnection(constr);mycon.Open();string sql="INSERT Users ( name, Password, RealName)" +"VALUES (@UserName, @Password, @RealName)";MySqlParameter[] para = new MySqlParameter[]{new MySqlParameter("@Name", "user.Name"),new MySqlParameter("@Password", "user.Password"),new MySqlParameter("@RealName", "user.RealName")};MySqlCommand mycmd = new MySqlCommand(sql, mycon);mycmd.Parameters.AddRange(para);int newId = mycmd.ExecuteNonQuery();Response.Write(newId + "<br/>");错误:Column 'name' cannot be null说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: MySql.Data.MySqlClient.MySqlException: Column 'name' cannot be null源错误:行 38: MySqlCommand mycmd = new MySqlCommand(sql, mycon);行 39: mycmd.Parameters.AddRange(para);行 40: int newId = mycmd.ExecuteNonQuery();行 41:行 42: Response.Write(newId + "<br/>");源文件: c:\Documents and Settings\Administrator\桌面\JMC\jmc\mysqltest.aspx.cs 行: 40
添加回答
举报
0/150
提交
取消