G
Guest
I've been beating my head against the wall for a couple days now, and am
completely stumped.
I have a datagrid in a windows form which is bound to a strongly typed
dataset named MainCases. The dataset is a public static object in Class1.
when the form loads the SqlDataAdapter fills MainCases from its SQL 2000
parent table, tblMainCases. The user is able to make changes, when they hit
"save" it runs the following function.
The code runs without error, but has no effect on the master table either on
Insert or Delete. Sql Profiler doesn't show T-SQL statements INSERT or UPDATE
statements running against the database.
Any advice would be highly appreciated at this point. Thanks in advance!
Ande
private void UpdateCases()
{
Class1.myDS.MainCases.AcceptChanges();
//UPDATE
string sSQL = "UPDATE tblMainCases " +
"SET Role = @Role, Type = @Type, CaseNumber = @CaseNumber, Date = @Date,
OppParty = @OppParty, OppCounsel = @OppCounsel, Summary = @Summary " +
"WHERE Counter = @Counter;";
Class1.da.UpdateCommand = new SqlCommand(sSQL, Class1.cn);
Class1.da.UpdateCommand.Parameters.Add("@Counter", SqlDbType.Int, 8,
"Counter");
Class1.da.UpdateCommand.Parameters.Add("@Role", SqlDbType.VarChar, 50,
"Role");
Class1.da.UpdateCommand.Parameters.Add("@Type", SqlDbType.VarChar, 50,
"Type");
Class1.da.UpdateCommand.Parameters.Add("@CaseNumber", SqlDbType.VarChar,
50, "CaseNumber");
Class1.da.UpdateCommand.Parameters.Add("@Date", SqlDbType.DateTime, 8,
"Date");
Class1.da.UpdateCommand.Parameters.Add("@OppParty", SqlDbType.VarChar,
50, "OppParty");
Class1.da.UpdateCommand.Parameters.Add("@OppCounsel", SqlDbType.VarChar,
50, "OppCounsel");
Class1.da.UpdateCommand.Parameters.Add("@Summary", SqlDbType.Text, 16,
"Summary");
//INSERT
sSQL = "INSERT INTO tblMainCases (AccountKey, Role, Type, CaseNumber,
Date, OppParty, OppCounsel, Summary) " +
"VALUES (@AccountKey, @Role, @Type, @CaseNumber, @Date, @OppParty,
@OppCounsel, @Summary);";
Class1.da.InsertCommand = new SqlCommand(sSQL, Class1.cn);
Class1.da.InsertCommand.Parameters.Add("@AccountKey", SqlDbType.Int, 4,
"AccountKey");
Class1.da.InsertCommand.Parameters.Add("@Role", SqlDbType.VarChar, 12,
"Role");
Class1.da.InsertCommand.Parameters.Add("@Type", SqlDbType.VarChar, 50,
"Type");
Class1.da.InsertCommand.Parameters.Add("@CaseNumber", SqlDbType.VarChar,
50, "CaseNumber");
Class1.da.InsertCommand.Parameters.Add("@Date", SqlDbType.DateTime, 8,
"Date");
Class1.da.InsertCommand.Parameters.Add("@OppParty", SqlDbType.VarChar,
50, "OppParty");
Class1.da.InsertCommand.Parameters.Add("@OppCounsel", SqlDbType.VarChar,
50, "OppCounsel");
Class1.da.InsertCommand.Parameters.Add("@Summary", SqlDbType.Text, 16,
"Summary");
Class1.da.Update(Class1.myDS.MainCases);
}
completely stumped.
I have a datagrid in a windows form which is bound to a strongly typed
dataset named MainCases. The dataset is a public static object in Class1.
when the form loads the SqlDataAdapter fills MainCases from its SQL 2000
parent table, tblMainCases. The user is able to make changes, when they hit
"save" it runs the following function.
The code runs without error, but has no effect on the master table either on
Insert or Delete. Sql Profiler doesn't show T-SQL statements INSERT or UPDATE
statements running against the database.
Any advice would be highly appreciated at this point. Thanks in advance!
Ande
private void UpdateCases()
{
Class1.myDS.MainCases.AcceptChanges();
//UPDATE
string sSQL = "UPDATE tblMainCases " +
"SET Role = @Role, Type = @Type, CaseNumber = @CaseNumber, Date = @Date,
OppParty = @OppParty, OppCounsel = @OppCounsel, Summary = @Summary " +
"WHERE Counter = @Counter;";
Class1.da.UpdateCommand = new SqlCommand(sSQL, Class1.cn);
Class1.da.UpdateCommand.Parameters.Add("@Counter", SqlDbType.Int, 8,
"Counter");
Class1.da.UpdateCommand.Parameters.Add("@Role", SqlDbType.VarChar, 50,
"Role");
Class1.da.UpdateCommand.Parameters.Add("@Type", SqlDbType.VarChar, 50,
"Type");
Class1.da.UpdateCommand.Parameters.Add("@CaseNumber", SqlDbType.VarChar,
50, "CaseNumber");
Class1.da.UpdateCommand.Parameters.Add("@Date", SqlDbType.DateTime, 8,
"Date");
Class1.da.UpdateCommand.Parameters.Add("@OppParty", SqlDbType.VarChar,
50, "OppParty");
Class1.da.UpdateCommand.Parameters.Add("@OppCounsel", SqlDbType.VarChar,
50, "OppCounsel");
Class1.da.UpdateCommand.Parameters.Add("@Summary", SqlDbType.Text, 16,
"Summary");
//INSERT
sSQL = "INSERT INTO tblMainCases (AccountKey, Role, Type, CaseNumber,
Date, OppParty, OppCounsel, Summary) " +
"VALUES (@AccountKey, @Role, @Type, @CaseNumber, @Date, @OppParty,
@OppCounsel, @Summary);";
Class1.da.InsertCommand = new SqlCommand(sSQL, Class1.cn);
Class1.da.InsertCommand.Parameters.Add("@AccountKey", SqlDbType.Int, 4,
"AccountKey");
Class1.da.InsertCommand.Parameters.Add("@Role", SqlDbType.VarChar, 12,
"Role");
Class1.da.InsertCommand.Parameters.Add("@Type", SqlDbType.VarChar, 50,
"Type");
Class1.da.InsertCommand.Parameters.Add("@CaseNumber", SqlDbType.VarChar,
50, "CaseNumber");
Class1.da.InsertCommand.Parameters.Add("@Date", SqlDbType.DateTime, 8,
"Date");
Class1.da.InsertCommand.Parameters.Add("@OppParty", SqlDbType.VarChar,
50, "OppParty");
Class1.da.InsertCommand.Parameters.Add("@OppCounsel", SqlDbType.VarChar,
50, "OppCounsel");
Class1.da.InsertCommand.Parameters.Add("@Summary", SqlDbType.Text, 16,
"Summary");
Class1.da.Update(Class1.myDS.MainCases);
}