Page 1 of 1

a problem with writing code (vb.net)

Posted: Sat 11 Jun 2005 18:22
by XYZ
when I try to to write the example...

Dim adapter as MySqlDataAdapter
Dim cmd as MySqlCommand
Dim dataSet as DataSet
cmd.CommandText = "insert into animals (id, name) values (:id, :name); select id, name from animals where id = last_insert_id()"
...
adapter.Update(dataSet)

I get "MySqlDataAdapter/MySqlCommand is not defined" errors.
I do have the MySql toolbox and it's working alright.
What am I doing wrong...?

thanks in advance...

Posted: Tue 14 Jun 2005 07:23
by Serious
The right code is

Code: Select all

Dim adapter As MySqlDataAdapter = New MySqlDataAdapter
    Dim connection As MySqlConnection = New MySqlConnection("host=server;user=root;password=root;database=test;")
    Dim commandBuilder As MySqlCommandBuilder = New MySqlCommandBuilder
    Dim command As MySqlCommand = New MySqlCommand("select * from dept", connection)
    adapter.SelectCommand = command REM set SelectCommand Property here
    commandBuilder.DataAdapter = adapter REM use command builder to generate insert, update, delete commands
    Dim ds As DataSet = New DataSet

    connection.Open()
    Try
      adapter.Fill(ds)
...
      adapter.Update(ds)
    Finally
      connection.Close()
    End Try

Posted: Wed 15 Jun 2005 02:11
by Guest
Thanks so much for the answer, however, the problem remains, somehow the .net still doest recognize mysqlnet elements, it's like these things are not defined or something is not included. The error shows before I even debug the project because somehow I can't get it to work with mysqlnet types.
Can it be because I've got only the standard edition?

Posted: Tue 21 Jun 2005 07:10
by Serious
Do you include required reference (CoreLab.MySql) to your project?

Posted: Mon 27 Jun 2005 09:45
by Guest
I think I did, but just incase how do you do that???

Posted: Mon 27 Jun 2005 10:05
by Serious
Every project node in the 'Solution Explorer' tree has a 'References' node.
Make sure that 'CoreLab.MySql' item is present there.