1
votes

Can anybody help me, the following code vb6 is working fine in windows 7 32 bit but not working in windows 10 32 or windows 10 64 bit.                    

My vb6 code for dsn creation for mysql database odbc driver 3.51 is as under :-

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

Dim Attr as string

 Attr = "SERVER=localhost" & Chr(0)
        Attr = Attr & "DSN=ABC" & Chr(0)
        Attr = Attr & "DESCRIPTION=DSN For ABC" & Chr(0)
        Attr = Attr & "DATABASE=mysqltestdb" & Chr(0)
        Attr = Attr & "User=root" & Chr(0)
        Attr = Attr & "Password=abctest" & Chr(0)
        Attr = Attr & "option=2" & Chr(0)
        iReturn = SQLConfigDataSource(0, 1, "MySql ODBC 3.51 Driver", Attr)
1
You listed several windows variants in the "not working" section - is that written correctly? Because you list a 32 bit version there while stating that this is a 64 bit problem. (Note that you can edit the text of your question if needed).StayOnTarget

1 Answers

1
votes

On Windows 64-bit systems, 32 bit versions of DLLs are located in the "C:\Windows\SysWOW64" folder. By default, SQLConfigDataSource is loading from the "C:\Windows\System32" folder which contains 64-bit DLLs, which causes the function to error out.

I know this folder naming seems backwards, but it really is how it's designed and this explains why that's the case.

Declare the function as follows and then try:

Private Declare Function SQLConfigDataSource _ 
Lib "C:\Windows\SysWOW64\ODBCCP32.DLL" (ByVal hwndParent As Integer, _ 
                                        ByVal fRequest As Integer, _ 
                                        ByVal lpszDriver As String, _ 
                                        ByVal lpszAttributes As String) As Integer