We must add reference for Microsoft Activex Data Object.Go to
menu add reference in Project-> Add Reference
after that choose Tab Com and choose Microsoft ActiveX Data Objects Library.
After this step we can try to VB .net code.
Second Step :
Add Imports statement ADODB
Imports ADODB
After Imports ADODB then we try to connect database.The first step is we declaration
variable for connect to database.
Dim con As New ADODB.Connection
After declaration we can open connection database using connection String.
Example we have database name Employee with user:'admin' and password:'admin' and we connect via ODBC.
so we create connection string like this :
Dim ConnectionString as string
ConnectionString="Persist Security Info=False;UID=admin;pwd=admin;DSN=admin";
After define Connection String we can open connection with con variable.
con.Open ConnectionString,null,null,0
No comments:
Post a Comment
Your Comment