|
-
Jan 21st, 2010, 12:57 AM
#1
Thread Starter
PowerPoster
MySQL adapter test: Need Testers
Hi Guys,
I need for you guys who have vb.net 2008 and mysql 5 to please do me a favour. I have added a bindingsource, dataadapter, datagridview to my form.
I fill a datatable using the dataadapter. and i set the adapter.missingschemaaction = missingschemaaction.AddwithKey. i set the insertcommand,updatecommand and deletecommand for the adapter as well.
however, when i click on the datagridview to add new rows a new temporary primary key is not generated in my datatable.
Can someone please test this and let me know if their primary keys get generated. i will greatly appreciate it. then I can determine whether i am maming a mistake.
I've done this with access and sql server 2005 with no problems. im using MySQL.Net connector 6.1.2
-
Jan 21st, 2010, 01:30 AM
#2
Re: MySQL adapter test: Need Testers
Does the MySQL table have an identity column set, or whatever the MySQL equivalent is?
While I understand that, if there's a problem with your code, you'd like to fix it, do keep in mind that there's nothing to stop your setting the AutoIncrementSeed and AutoIncrementStep properties of your DataColumn manually after populating the DataTable.
-
Jan 21st, 2010, 01:56 AM
#3
Thread Starter
PowerPoster
Re: MySQL adapter test: Need Testers
thanks JM. afaik you just have to set the column to the primary key and autoincrement gets ticked in the database.
i've tried this, and it has no effect:
Code:
Private Function GetGrandParentTable() As DataTable
Dim table As New DataTable("GrandParent")
CatAdapter.Fill(table)
table.Columns(0).AutoIncrementStep = 1
table.Columns(0).AutoIncrementSeed = 1
Return table
End Function
i've tried this in my immediate window:
Code:
?table.Columns(0).AutoIncrement
and it returns false.
when I try to set the value:
Code:
table.Columns(0).AutoIncrement = True
i get this error:
Code:
Cannot change AutoIncrement of a DataColumn with type 'UInt32' once it has data.
-
Jan 21st, 2010, 02:02 AM
#4
Re: MySQL adapter test: Need Testers
Hmmm... maybe there IS something to stop your doing that. You could add the column yourself first but that is certainly not the way it SHOULD have to be done. I don't think I can help further I'm afraid as I don't use MySQL. That said, I wouldn't be surprised if you had to set the autoincrement property on the column yourself. The identity property of a column certainly doesn't get set automatically in SQL Server.
-
Jan 21st, 2010, 02:11 AM
#5
Thread Starter
PowerPoster
Re: MySQL adapter test: Need Testers
no prob. thanks for the suggestion though
the id columns on all my tables autoincrement when i do an insert though, so i doubt that is the issue.
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
|