Click here to Skip to main content
15,888,733 members
Home / Discussions / C#
   

C#

 
GeneralExport from textbox to external file Pin
Code Toad12-Aug-05 4:48
Code Toad12-Aug-05 4:48 
GeneralRe: Export from textbox to external file Pin
Guffa12-Aug-05 5:47
Guffa12-Aug-05 5:47 
GeneralRe: Export from textbox to external file Pin
Code Toad12-Aug-05 9:04
Code Toad12-Aug-05 9:04 
GeneralScale and Transform Location Pin
GoodQuestion12-Aug-05 4:42
GoodQuestion12-Aug-05 4:42 
GeneralRe: Scale and Transform Location Pin
Werdna12-Aug-05 9:17
Werdna12-Aug-05 9:17 
GeneralProblem with TapControl Pin
Anonymous12-Aug-05 4:29
Anonymous12-Aug-05 4:29 
GeneralRe: Problem with TapControl Pin
mhmo13-Aug-05 7:32
mhmo13-Aug-05 7:32 
GeneralGet the value of primary key as output parameter... Pin
signbit12-Aug-05 4:25
signbit12-Aug-05 4:25 
I am not using stored procedures, my table looks like this:

+---------------+--------------+------+-----+---------+----------------+
| Field         | Type         | Null | Key | Default | Extra          |
+---------------+--------------+------+-----+---------+----------------+
| ProviderID    | int(11)      |      | PRI | NULL    | auto_increment |
| CompanyTitle  | varchar(255) | YES  |     | NULL    |                |
| CompanyEmail  | varchar(50)  | YES  |     | NULL    |                |
| Website       | varchar(50)  | YES  |     | NULL    |                |
+---------------+--------------+------+-----+---------+----------------+


The value of ProviderID is automatically generated by the database, to insert data into the table, I am using the following code:


MySqlCommand myInsertCmd = new MySqlCommand(
"INSERT INTO myTable (ComapanyTitle, CompanyEmail, Website, ContactPerson, AddressID)
VALUES(?CompanyTitle, ?CompanyEmail, ?Website, ?ContactPerson, ?AddressID)", myConnection);

myInsertCmd.Parameters.Add("?CompanyTitle", MySqlDbType.VarChar,
		255, "CompanyTitle");
myInsertCmd.Parameters.Add("?CompanyEmail", MySqlDbType.VarChar, 50, "CompanyEmail);

myInsertCmd.Parameters.Add("?Website", MySqlDbType.VarChar, 50, "CompanyEmail);

myAdapter.InsertCommand = myInsertCmd;


now, whenver I get a new row, I immediately insert it into the database, like this:

myAdapter.Update(myDataTable);


Is there a way, I can get the primaryKey of the newly insert row?

Thanks...

- A programmer's national anthem; "AAAAAHHHHH!!!!"
GeneralRe: Get the value of primary key as output parameter... Pin
Guffa12-Aug-05 5:25
Guffa12-Aug-05 5:25 
GeneralUserControl interaction Pin
tehe12-Aug-05 3:53
tehe12-Aug-05 3:53 
GeneralRe: UserControl interaction Pin
Libor Tinka12-Aug-05 5:02
Libor Tinka12-Aug-05 5:02 
Generalrecieving UCHAR buffer in C# from C DLL Pin
A T I F12-Aug-05 3:23
A T I F12-Aug-05 3:23 
GeneralMdiChildActivate Pin
bouli12-Aug-05 3:16
bouli12-Aug-05 3:16 
GeneralMasking the TextBox Pin
zaboboa12-Aug-05 3:15
zaboboa12-Aug-05 3:15 
GeneralRe: TextBox Pin
Marshall12-Aug-05 3:53
Marshall12-Aug-05 3:53 
GeneralRe: TextBox Pin
Abymoh12-Aug-05 7:25
Abymoh12-Aug-05 7:25 
GeneralRe: TextBox Pin
zaboboa12-Aug-05 7:28
zaboboa12-Aug-05 7:28 
GeneralMdiParent Question Pin
Jassim Rahma12-Aug-05 2:59
Jassim Rahma12-Aug-05 2:59 
GeneralRe: MdiParent Question Pin
bouli12-Aug-05 3:10
bouli12-Aug-05 3:10 
GeneralRe: MdiParent Question Pin
Jassim Rahma12-Aug-05 3:15
Jassim Rahma12-Aug-05 3:15 
GeneralRe: MdiParent Question Pin
bouli12-Aug-05 3:18
bouli12-Aug-05 3:18 
GeneralRe: MdiParent Question Pin
Jassim Rahma12-Aug-05 7:34
Jassim Rahma12-Aug-05 7:34 
GeneralRe: MdiParent Question Pin
dmccabe212-Aug-05 9:03
dmccabe212-Aug-05 9:03 
GeneralRe: MdiParent Question Pin
Jassim Rahma12-Aug-05 11:07
Jassim Rahma12-Aug-05 11:07 
GeneralRe: MdiParent Question Pin
dmccabe212-Aug-05 12:22
dmccabe212-Aug-05 12:22 

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.