• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

About ODBC Data Source 32 bits

I used ODBC to make a link to the MS Access Database.
Is there possible to create a vb program that will do this for me, instead of going to the control panel ?
  • 3
  • 2
1 Solution
Actually the easier way would be to use a DSNles connection...This way you can let others use the program with a centralized DB without the need to create a DSN on each Machine... a sample connection sting appears below...

connString = "Provider = SQLOLEDB;Data source = mySQLServer;Initial Catalog = someDataBase;user id= someUser;password= aPassword"

This of course is for a SQL server but it is the same syntax for an Access DB.

Check out the ADO objects for a further explanation...
tanc02Author Commented:
OK, but I think I still have to use ODBC to connect to the db right ?
In order to explain a little easier the following code walks through opening a connection setting up a command object with 3 parameters and calling a stored proceedure on a SQL server and putting the result set into a recordset that can be used. Then it cleans up. This little example can be run from any machine on the network and does not require any DSN defined on the machines...This is what a DSN-less connection is. No ODBC calls. ActiveX Data Objects only.

Set dbConn1 = New ADODB.Connection
Set dbComm = New ADODB.Command
Set dbRec = New ADODB.Recordset

Set cNodeParam1 = dbComm.CreateParameter(fldCNodeID, adInteger, adParamInput, 4)
    Set cNodeParam2 = dbComm.CreateParameter(fldCName, adVarChar, adParamInput, 50)
    Set cNodeParam3 = dbComm.CreateParameter(fldCDesc, adVarChar, adParamInput, 255)
    dbComme.Parameters.Append cNodeParam1
    dbComm.Parameters.Append cNodeParam2
    dbComm.Parameters.Append cNodeParam3

dbComm.Parameters(0) = nextCNodeId
    dbComm.Parameters(1) = lclCNodeName
    dbComm.Parameters(2) = lclCNodeDesc

With dbComm
    .ActiveConnection = dbConn1
    .CommandType = adCmdStoredProc
End With

set dbRec = dbComm.Execute

"DO Something with the recordset"

Set dbRec = Nothing
Set dbComm = Nothing
Set dbConn1 = Nothing

tanc02Author Commented:
mmpis :

Can you post your comments as answer, so I can award the points to you
Your wish is granted...I do hope that the walk through helped...

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now