DataGrid and INSERT problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I use a stored procedure to insert data into a table and when the
Datagrid refreshes two new columns are added. The dataSet is set up with one
table with NO columns defined. Please help me on this. I have screen shots of
the before and after.

Here is the code:

sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = SQLInsertSP;
sqlCommand.Parameters.Add("@aid",SqlDbType.Int,4);
sqlCommand.Parameters.Add("@type",SqlDbType.VarChar,50);
sqlCommand.Parameters["@aid"].Value = tAID;
sqlCommand.Parameters["@type"].Value = tValue;
sqlADBAdapt.InsertCommand = sqlCommand;

//This is the point where the Insert Statement is working but its adding two
new columns

sqlADBAdapt.Update(dataSet1);
sqlCommand.Parameters.Clear();
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = SQLSelectSP;
try{
sqlADBAdapt.SelectCommand = sqlCommand;
sqlADBAdapt.Fill(dataSet1.Tables[0]);
}
catch(SqlException ae){
MessageBox.Show(ae.Message.ToString());
}
dataGrid1.DataSource = dataTable1;
dataGrid1.ReadOnly=true;
 
What is the value of SQLSelectSP?




mattgcon said:
I wrote this awhile ago, but no one answered it, Can anyone please help me on
this

mattgcon said:
When I use a stored procedure to insert data into a table and when the
Datagrid refreshes two new columns are added. The dataSet is set up with one
table with NO columns defined. Please help me on this. I have screen shots of
the before and after.

Here is the code:

sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = SQLInsertSP;
sqlCommand.Parameters.Add("@aid",SqlDbType.Int,4);
sqlCommand.Parameters.Add("@type",SqlDbType.VarChar,50);
sqlCommand.Parameters["@aid"].Value = tAID;
sqlCommand.Parameters["@type"].Value = tValue;
sqlADBAdapt.InsertCommand = sqlCommand;

//This is the point where the Insert Statement is working but its adding two
new columns

sqlADBAdapt.Update(dataSet1);
sqlCommand.Parameters.Clear();
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = SQLSelectSP;
try{
sqlADBAdapt.SelectCommand = sqlCommand;
sqlADBAdapt.Fill(dataSet1.Tables[0]);
}
catch(SqlException ae){
MessageBox.Show(ae.Message.ToString());
}
dataGrid1.DataSource = dataTable1;
dataGrid1.ReadOnly=true;
 
mattgcon said:
I wrote this awhile ago, but no one answered it, Can anyone please help me on
this

I suggest you ask on the .adonet newsgroup, with a more descriptive
subject line.
 
Back
Top