-
July 7th, 2005, 04:12 AM
#1
Insert into/update a database using MSRDC but not with SQL
Hello.
I'm making a program which connects to a MySQL dtabase, reads some tables, and populates comboboxes. The user fills a form with the comboboxes and textboxes and I'm ready to update the database.
I want to use an MSRDC control but I don't want to use an SQL command because the database has an Auto Inc Key which I want to retrieve after I update the database (also it should be faster).
So far I have this:
Form1.MSRDCSpot.Connect = ConnectionString
Form1.MSRDCSpot.Refresh
which works perfectly if I want to read from the database, but when I write
MSRDCSpot.BeginTrans
it replies "The connection is not open".
Can anyone give me an example as i can't find anything on the internet (without the use of SQL commands).
Thanks.
Visit www.greekroms.net
Greek translations of roms
-
July 7th, 2005, 05:55 PM
#2
Re: Insert into/update a database using MSRDC but not with SQL
Although I cannont help you with MSRDC, you can most certainly use an Insert command with MySQL then get the Auto Inc field.
If you do...
INSERT INTO MyTable (Name, DOB) VALUES ('SoToasty', '2005-01-01');
Followed by,
SELECT last_insert_id() as ID;
You will get back the AutoIncrement field from MySQL. The last_insert_id() function works on a per connection basis, so if you have more than one connection you can insert into multiple tables, and then use last_insert_id() to retrieve the ID from Multiple tables.
I don't know if this will help you but it is all I can offer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|