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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configure a dsn in VBA

Status
Not open for further replies.

Kawuet

Technical User
May 2, 2003
3
FR
I'm trying to configure a dsn in VBA. I will use it to switch between PERVASIVE and MSSQL for an application.

Let see the code :

DataSourceName = "P5COM"
DatabaseName = "XRTPVSW"
DriverPath = "c:\xrt\pvsw\bin\w3odbcci.dll"
DriverName = "Pervasive ODBC Engine Interface"

lResult = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\" & _
DataSourceName, hKeyHandle)

lResult = RegSetValueEx(hKeyHandle, "DBQ", 0&, REG_SZ, _
ByVal DatabaseName, Len(DatabaseName))
lResult = RegSetValueEx(hKeyHandle, "Driver", 0&, REG_SZ, _
ByVal DriverPath, Len(DriverPath))

lResult = RegCloseKey(hKeyHandle)

lResult = RegCreateKey(HKEY_LOCAL_MACHINE, _
"SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", hKeyHandle)
lResult = RegSetValueEx(hKeyHandle, DataSourceName, 0&, REG_SZ, _
ByVal DriverName, Len(DriverName))
lResult = RegCloseKey(hKeyHandle)

I have the same code for the MSSQL part. It's working with MSSQL, when I try to get into the product with the P2000 SQL DB I have the error: 80004005 unspecified error ???

I try different actions but no one works...
pleas can you help me ?
 
Why not use DTO or DTI or ODBC API and do it the safe way. There's code on Pervasive's web site. Setting registry values isn't always a good idea. Registry rights may be an issue.

info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
I agree, use DTO or the ODBC API. You can try the code in thread318-528711.

Thanks and Good Luck!

zemp
 
I try to download the papers ODBC&DSN, VB ODBC&DTO, VB DTI&ODBC, but no one of the links are working for me...

I try a search on Google but I don't find any other doc...

Does it exist ?

Thanks
 
What do you mean the links aren't working? I was able to download them. They do however require a password to open the ZIP file. Make sure you specify the password when opening the ZIP file. You could also try the code mentioned above by Zemp.


info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top