插入记录是遇到未能找到存储过程的情况
string tempusername;
tempusername = username.Text;
string connstr;
connstr = ConfigurationSettings.AppSettings[ "connstr "];
SqlConnection conn = null;
DataSet ds = new DataSet();
conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "insert into user_login(usernam) value( ' " + tempusername + " ') ";
cmd.Parameters.Add( "@username ", SqlDbType.VarChar, 10).Value = tempusername;
cmd.Connection = conn2;
SqlDataAdapter ad=new SqlDataAdapter();
ad.InsertCommand = cmd;
cmd.ExecuteNonQuery();
conn.Close();
为什么运行后说我么有找到存储过程未能找到存储过程 'insert into user_login(username) value( 'miser ') '。
(miser)是我打的用户名
------解决方案--------------------string tempusername;
tempusername = username.Text;
string connstr;
connstr = ConfigurationSettings.AppSettings[ "connstr "];
SqlConnection conn = null;
DataSet ds = new DataSet();
conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into user_login(usernam) value( ' " + tempusername + " ') ";
cmd.Parameters.Add( "@username ", SqlDbType.VarChar, 10).Value = tempusername;
cmd.Connection = conn2;
SqlDataAdapter ad=new SqlDataAdapter();
ad.InsertCommand = cmd;
cmd.ExecuteNonQuery();
conn.Close();
------解决方案--------------------cmd.CommandType = Com