Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Access connection string converted to SQL

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
Greetings, I feel foolish asking for this. I have this script and SQL database but the script is designed for an access database. I need the connection information converted to SQL but try as I might, I keep getting various errors. There is something I'm not doing right. Here's the original code:
Code:
Sub subConnectionOpen
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
sProviderName = "Microsoft.Jet.OLEDB.4.0"
iCursorType = 1
iLockType = 3
sDataSource = "\\MAINSERVER\C$\pcinfo.mdb"
objCon.Provider = sProviderName
objCon.Properties("Data Source") = sDataSource
objCon.Open
objRS.CursorType = iCursorType
objRS.LockType = iLockType
objRS.Source = "Computerinfo"
objRS.ActiveConnection = objCon
objRS.Open
End Sub
Any thoughts would be helpful. Thanks in advance!
 
Meldrape,

Sql is Sql and connections are connections. What are you trying to connect to? MYSQL, SQLServer ORacle, MSSQL SERVER?

Here's a sample connection string below to MYSQL followed by one for oracle

Yours would probably be.

objcon.open ="Driver ="Microsoft.Jet.OLEDB.4.0;Datasource=\\MAINSERVER\C$\pcinfo.mdb;UID=MyUiD; PWD=MyPWD. "


Hope this helps

Dan

conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& " DATABASE=test;"_
& "UID=MyUid;PWD=MyPwd"

CONNSTR = "Provider=MSDAORA.1;User ID='" & USERID & "';PASSWORD='" & Password & "';Data Source='" & SERVERNAME & "';Persist Security Info=true"

conn.open CONNSTR
 
Thanks, Dan. It's a SQL2000 database I'm trying to connect to. I'll keep playing around with it. Thanks again.
 
I recommend checking here:


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks for that link, Tom. I just figured out how to do the standard SQL connection and it's working fine now. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top