我要在這裏瘋狂,有人可以告訴我什麼是錯,此代碼在ASP.NET上插入的SqlCommand錯誤
con.Open();
cmd = new SqlCommand("INSERT INTO COUNTERS(COUNTER_START, COUNTER_CURRENT, COUNTER_NEXT, COUNTER_TYPE, COUNTER_DATE_CREATED, COUNTER_TIME_CREATED, COUNTER_CREATED_BY) " +
"VALUES(@counter_start, @counter_current, @counter_next, @counter_type, @date, @time, @user)", con);
cmd.Parameters.Add("@counter_start", SqlDbType.Int).Value = counter_start.Text;
cmd.Parameters.Add("@counter_current", SqlDbType.Int).Value = counter_current.Text;
cmd.Parameters.Add("@counter_next", SqlDbType.Int).Value = counter_next.Text;
cmd.Parameters.Add("@counter_type", SqlDbType.VarChar, 10).Value = counter_type.Text;
cmd.Parameters.Add("@date", SqlDbType.VarChar, 20).Value = date;
cmd.Parameters.Add("@time", SqlDbType.VarChar, 20).Value = time;
cmd.Parameters.Add("@user", SqlDbType.VarChar, 50).Value = user;
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
我得到這個錯誤
的參數化查詢'(@counter_start INT,@ counter_current INT,@ counter_next INT,@ COUN' 預計參數 '@user',這是 不供給
任何輸入將被確實appre引用它。
您需要嘗試/終止您的Dispose()調用,否則您最終可能會斷開連接。 – 2012-07-27 03:46:26
謝謝。我確實有他們,我只是包含了我遇到的一段代碼。 – jorame 2012-07-27 03:51:38