次のコードには問題があるようです。次のコード スニペットを使用してデータベースに値を挿入したいと考えています。
DataTable dtUsers = new DataTable("tblUsers");
BindingSource bsUsers = new BindingSource();
SqlDataAdapter daUsers = new SqlDataAdapter("usp_GetUsers", Properties.Resources.ConnectionString);
daUsers.InsertCommand = new SqlCommand("usp_InsertNewUser");
daUsers.InsertCommand.Connection = new SqlConnection(Properties.Resources.ConnectionString);
daUsers.InsertCommand.CommandType = CommandType.StoredProcedure;
daUsers.InsertCommand.Parameters.Clear();
daUsers.InsertCommand.Parameters.Add("@username", SqlDbType.VarChar, 50).Value = txtUser.Text;
daUsers.InsertCommand.Parameters.Add("@password", SqlDbType.VarChar, 50).Value = txtPass.Text;
daUsers.InsertCommand.Parameters.Add("@userType", SqlDbType.Int).Value = cbxUserType.SelectedValue;
daUsers.Update(dtUsers);
質問する前に、ストアド プロシージャは正常に動作しています。また、上記の InsertCommand を SelectCommand に変更して Fill メソッドを呼び出すと、すべて正常に動作します。Select/Fill コンボを使用している場合、データ アダプタの挿入/更新メソッドが正常に機能しないため、これはイライラさせられます。私もそれを監視したので、データ行は挿入されていません。また、例外も発生しません。アル