Click here to Skip to main content
15,894,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am using the following code to create a dsn automatically in my vb6 code.

''''in declarations part:

Private Const a = 4&

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

'''and function call to create dsn:

i = SQLConfigDataSource(0, a, "Microsoft Access Driver (*.mdb)",_ "DSN=MyDsn;DBQ=" & App.Path & "\Data\MyDb.mdb")

The above code works fine in XP. But in vista platform, it is returning 0 to i, ie., the dsn is not getting created. Any advice to resolve this problem will be appreciated.

Thanks
Posted

Given that VB6 was obsolete when Vista was released, and continues to be unsupported, the question becomes, why would you use it ?
 
Share this answer
 
AR@JR wrote:
The above code works fine in XP. But in vista platform, it is returning 0 to i, ie., the dsn is not getting created. Any advice to resolve this problem will be appreciated.


Run the application as an Administrator :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900