473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DataGrid and INSERT problem

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.VarCha r,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;
Nov 16 '05 #1
3 3312
I wrote this awhile ago, but no one answered it, Can anyone please help me on
this

"mattgcon" wrote:
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.VarCha r,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;

Nov 16 '05 #2
What is the value of SQLSelectSP?


"mattgcon" <ma******@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
I wrote this awhile ago, but no one answered it, Can anyone please help me on this

"mattgcon" wrote:
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.VarCha r,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;

Nov 16 '05 #3
mattgcon <ma******@discussions.microsoft.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
7
by: Pierluigi Terzoli | last post by:
Hi everybody, I need help for this problem: I'm using a DataGrid to Insert/Modify/Cancel data from a single table. At the moment, every cell modification of a pre-existing row is correctly update...
8
by: Inigo Jimenez | last post by:
I have an ASP .net web application installed in a Windows 2003 server. This web application has a webform that has a Datagrid. This Datagrid is filled with the data of a SQL table. I have a...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
16
by: tshad | last post by:
I am trying to center a button in a datagrid column in asp.net and it doesn't seem to work. I have the following: <asp:TemplateColumn ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
0
by: Charles Watson | last post by:
datagrid won't refresh I can see in other groups that this is a big problem in vb6/sp5. any answers? I get data off a form of input boxes, insert it into the datagrid. I change something on...
10
by: Nick | last post by:
Hello, Please pardon my ignorance as I'm sure this is easy to do. I have a datagrid where I want to let the user delete columns. I added a context menu to the datagrid that has a delete option....
0
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid...
5
by: rcoco | last post by:
Hi, I'm working on a asp.net project with a datagrid. I want the user to be adding data into Sql database using the datagrid. So I'm using a ListBox to do this and edit update and delete. I placed...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.