• 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 ?
0
tanc02
Asked:
tanc02
  • 3
  • 2
1 Solution
 
mmipsCommented:
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...
0
 
tanc02Author Commented:
OK, but I think I still have to use ODBC to connect to the db right ?
0
 
mmipsCommented:
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
    .CommandText = SOMESTOREDPROCEDURE
    .CommandType = adCmdStoredProc
End With

set dbRec = dbComm.Execute

"DO Something with the recordset"

dbConn1.Close
Set dbRec = Nothing
Set dbComm = Nothing
Set dbConn1 = Nothing


0
 
tanc02Author Commented:
mmpis :

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

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