Insert to MySQL DB from Winforms app

  • Thread starter Thread starter Russ Green
  • Start date Start date
R

Russ Green

Does anyone have any code samples of insert data into a MySQL db located
somewhere on the web from a winforms app?

TIA

Russ
 
' Make sure first that you have the MySQL ODBC Driver installed :

Dim MyConnection As System.Data.Odbc.OdbcConnection

MyConnection = New System.Data.Odbc.OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};SERVER=server_name;DATABASE=base_name;USER=login;PASSWORD=pass")

Dim MyCommand As System.Data.Odbc.OdbcCommand = New Odbc.OdbcCommand("INSERT
INTO Tab1 (col1) VALUES (1)", MyConnection)

MyConnexion.Open()

MyCommand.ExecuteNonQuery()
 
Thanks,

Russ


NM said:
' Make sure first that you have the MySQL ODBC Driver installed :

Dim MyConnection As System.Data.Odbc.OdbcConnection

MyConnection = New System.Data.Odbc.OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};SERVER=server_name;DATABASE=base_name;USER=login;PASSWORD=pass")

Dim MyCommand As System.Data.Odbc.OdbcCommand = New Odbc.OdbcCommand("INSERT
INTO Tab1 (col1) VALUES (1)", MyConnection)

MyConnexion.Open()

MyCommand.ExecuteNonQuery()
 
Does anyone have any code samples of insert data into a MySQL db located
somewhere on the web from a winforms app?

TIA

Russ

You might want to check out the ByteFX MySQL data provider. It's free.
It works on both .NET and Mono (so, it is portable to Linux :), and it
seems to work pretty well for the little testing I've done with it so
far.

The nice thing about it is that it is 100% C# code, so there is not
need to install any of the MySQL client libraries...

http://sourceforge.net/projects/mysqlnet/

HTH
 
Back
Top