Results 1 to 5 of 5

Thread: MySQL adapter test: Need Testers

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    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
  •  



Click Here to Expand Forum to Full Width