Click here to Skip to main content
16,013,642 members
Home / Discussions / C#
   

C#

 
GeneralPassing Value Types by Reference Pin
paulsawyer22-Dec-04 15:00
paulsawyer22-Dec-04 15:00 
GeneralRe: Passing Value Types by Reference Pin
Heath Stewart22-Dec-04 19:17
protectorHeath Stewart22-Dec-04 19:17 
GeneralRe: Passing Value Types by Reference Pin
Salil Khedkar22-Dec-04 19:20
Salil Khedkar22-Dec-04 19:20 
GeneralProblem with Stored Procedure Pin
ronin177022-Dec-04 14:29
ronin177022-Dec-04 14:29 
GeneralRe: Problem with Stored Procedure Pin
Javier Lozano22-Dec-04 18:36
Javier Lozano22-Dec-04 18:36 
Generalproblem auto increment field Pin
Gedrain22-Dec-04 13:30
Gedrain22-Dec-04 13:30 
GeneralRe: problem auto increment field Pin
Skynyrd22-Dec-04 13:35
Skynyrd22-Dec-04 13:35 
GeneralRe: problem auto increment field Pin
Heath Stewart22-Dec-04 19:07
protectorHeath Stewart22-Dec-04 19:07 
As I already told you, you need to read the documentation. connection.BeginTransaction will not update your your changes. DataAdapter.Update will connect to the database using the connection string, update the changes, then disconnect. A transaction only works when you're connected, and Update encapsulates that.

And as I also said before that the other post mentioned, you need to combine your INSERT statement with a SELECT statement and NOT insert your auto-generated fields, like so:
SqlCommand insertCommand = connection.CreateCommand();
insertCommand.CommandText = "insert into brands (name) values (@name); select id, name from brands";
insertCommand.Parameters.Add("@name", SqlDbType.NVarChar, 40).Value = "Bob";
adapterBrands.Update(ds.GetChanges(), "brands");
You may also need to set up the TableMappings property to map unnamed tables (like Table, Table1, Table2, etc., that match up to result sets) in order to fill the right tables. If you don't and have a pre-configured DataSet, the result sets won't match up with the DataTables you've configured.

For simple SELECT statements just use a SqlCommandBuilder to construct the INSERT, UPDATE, and DELETE commands. It will automatically combine both the INSERT and SELECT statements for the InsertCommand property as I mentioned before. This information is all covered in the .NET Framework SDK.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: problem auto increment field Pin
Gedrain23-Dec-04 3:13
Gedrain23-Dec-04 3:13 
GeneralRe: problem auto increment field Pin
Heath Stewart23-Dec-04 4:59
protectorHeath Stewart23-Dec-04 4:59 
GeneralTextBox Pin
Aviv Halperin22-Dec-04 11:56
Aviv Halperin22-Dec-04 11:56 
GeneralRe: TextBox Pin
Heath Stewart22-Dec-04 12:11
protectorHeath Stewart22-Dec-04 12:11 
GeneralRe: TextBox Pin
Aviv Halperin22-Dec-04 12:17
Aviv Halperin22-Dec-04 12:17 
GeneralRe: TextBox Pin
Heath Stewart22-Dec-04 12:40
protectorHeath Stewart22-Dec-04 12:40 
GeneralRe: TextBox Pin
Aviv Halperin22-Dec-04 12:20
Aviv Halperin22-Dec-04 12:20 
GeneralRe: TextBox Pin
Skynyrd22-Dec-04 12:29
Skynyrd22-Dec-04 12:29 
GeneralRe: TextBox Pin
Aviv Halperin22-Dec-04 12:39
Aviv Halperin22-Dec-04 12:39 
GeneralRe: TextBox Pin
Skynyrd22-Dec-04 12:46
Skynyrd22-Dec-04 12:46 
GeneralRe: TextBox Pin
Heath Stewart22-Dec-04 12:50
protectorHeath Stewart22-Dec-04 12:50 
GeneralRe: TextBox Pin
Aviv Halperin22-Dec-04 13:13
Aviv Halperin22-Dec-04 13:13 
GeneralRe: TextBox Pin
Heath Stewart22-Dec-04 13:18
protectorHeath Stewart22-Dec-04 13:18 
GeneralRe: TextBox Pin
Aviv Halperin22-Dec-04 13:20
Aviv Halperin22-Dec-04 13:20 
GeneralRe: TextBox Pin
Matt Gerrans22-Dec-04 12:31
Matt Gerrans22-Dec-04 12:31 
GeneralRe: TextBox Pin
Aviv Halperin22-Dec-04 12:41
Aviv Halperin22-Dec-04 12:41 
GeneralRe: TextBox Pin
Heath Stewart22-Dec-04 12:43
protectorHeath Stewart22-Dec-04 12:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.