ODBC connection

BPM open discussion (Visio collaboration, PHP, MySQL) and best practices

Moderator: Moran Nave

ODBC connection

Postby Tal Jacob » Tue Mar 09, 2010 10:12 am

Hi,

How do I make ODBC connection to Mysql DB in VB?
Tal Jacob
 
Posts: 43
Joined: Thu Sep 24, 2009 7:15 pm

Re: ODBC connection

Postby Moran Nave » Tue Mar 09, 2010 10:28 am

Hi,

You can use ADO by making New ADODB.Connection, and use this function to connect to DB:

Code: Select all
Private Function ConnectString() As String
Dim strServerName as String
Dim strDatabaseName as string
Dim strUserName as string
Dim strPassword as string

    'Make sure that you d/l and install the MySQL Connector/ODBC 3.51 Driver

strServerName = "localhost"
strDatabaseName = "DatabaseName"
strUserName = "UserName"
strPassword ="Password"

ConnectString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
                "SERVER=" & strServerName & _
                ";DATABASE=" & strDatabaseName & ";" & _
                "USER=" & strUserName & _
                ";PASSWORD=" & strPassword  & _
                ";OPTION=3;"

End Function


Moran Nave,
ProcessGene Ltd.
Moran Nave
 
Posts: 102
Joined: Thu Oct 08, 2009 7:09 pm

Re: ODBC connection

Postby Tal Jacob » Wed Mar 31, 2010 5:56 pm

And how do I make a SELECT statement?
Tal Jacob
 
Posts: 43
Joined: Thu Sep 24, 2009 7:15 pm

Re: ODBC connection

Postby Moran Nave » Wed Mar 31, 2010 6:05 pm

Use Recordset,see this code:
Code: Select all
Set rs = New ADODB.Recordset       'Creates record set
strSQL = "SELECT * FROM table WHERE id = ..."
rs.Open strSQL, cn, strDBCursorType, strDBLockType, strDBOptions

And to get the results use: rs.GetString()

Moran Nave,
ProcessGene Ltd.
Moran Nave
 
Posts: 102
Joined: Thu Oct 08, 2009 7:09 pm


Return to Open discussion - BPM R&D

Who is online

Users browsing this forum: No registered users and 1 guest

cron