Create ODBC DSN using SQLConfigDataSource

G

Guest

I just installed Vista RC1 for testing our application. Our application
creates an ODBC data source for SQL Server using SQLConfigDataSource() in
Visual Basic 6. What was working in all previous versions of Windows is not
working in Vista RC1. The function returns zero and no data source is
created. And I am logged in as the Windows administrator. Here is a snippet
of code I am using:

Const ODBC_ADD_DSN = 1 'user data source
Const ODBC_ADD_SYS_DSN = 4 'system data source

Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal
hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal
lpszAttributes As String) As Long

strDriver = "SQL Server"
strAttributes = "DSN=TravCom" & Chr$(0) _
& "Database=TravCom" & Chr$(0) _
& "Description= TravCom Data Source" & Chr$(0) _
& "Server=(local)" & Chr$(0) _
& "Trusted_Connection=No" & Chr$(0)

MsgBox SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, strDriver, strAttributes)

Note that creating a user DSN works if I replace ODBC_ADD_SYS_DSN with
ODBC_ADD_DSN, I just can't create a system data source. I'm sure it has to do
with all the new security "features" in Vista. But being logged in as
administrator you would think I can avoid this somehow. Also, I can manually
create the system DSN using ODBC Administrator. I just can't do it using
SQLConfigDataSource as I have in the past. Anyone have a suggestion how I can
create a system data source using this Windows function? Thanks.
 
G

Guest

Ok, figured it out. All part of the nifty new "User Account Control" feature
(cough). If I run the application as an Administrator it works. Now I just
need to notify all my clients who plan on upgrading to Vista that they need
to do this. Very nice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top