# Adding reference in VB.Net



## soulfly (May 29, 2004)

I have a simple in vb.net and it's about adding a referenee to import it to the program.

I want to import *Microsoft.Data.Odbc* in my program to connect to my database in mySql. The problem is after typing *Imports Microsoft.*, there is no available *Data* reference in there. I tried adding other available list of reference but my problem is I don't know the specific reference to add (*Microsoft.Data.Odbc*) .


----------



## soulfly (May 29, 2004)

well my question has been solved (after searching in google about add-ins, modules in vb.net)

although, i have another problem and it's about adding fields in an existing tables in mysql.

here's my code
-----------------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=sample;" & _
"UID=root;" & _
"PASSWORD=password;" & _
"OPTION=3;"
Dim MyConnection As New OdbcConnection(MyConString)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection

Dim sqlString As String

sqlString = "INSERT INTO emp (num, name) VALUES (" & _
"PrepareStr(textbox1.text)" & "," & _
"PrepareStr(textbox2.text)"

MyConnection = New OdbcConnection(MyConString)
MyConnection.Open()
MyCommand = New OdbcCommand(sqlString, MyConnection)
MyCommand.ExecuteNonQuery()
----------------------------------------------------------------------

after compiling this code, i'm recieving an error message like this:

An unhandled exception of type 'Microsoft.Data.Odbc.OdbcException' occurred in microsoft.data.odbc.dll

Additional information: System error.

This error is pointed to _MyCommand.ExecuteNonQuery()_

Any help is highly appreciated


----------

