Installing and configuring ODBC drivers

Installing and configuring ODBC drivers

Post by Alsto » Fri, 16 Jul 1999 04:00:00



    Hi,

        How can I install and configure ODBC DSN's without passing through
the ODBC
    window in the Control Panel? By functions or DOS, or executables, or
INI's ... ??
        I am coding a Windows installation program, and I need to install
and configure
    data sources ( SQL Server, text, and DBase ). I am using InstallShield.

                    Please help me !

Francky

 
 
 

Installing and configuring ODBC drivers

Post by Alan Brewe » Fri, 16 Jul 1999 04:00:00


Can you execute something that will call the ODBC SQLConfigDataSource
function?  You can set that up to create data sources without poping a
dialog to the user.  For more information, see the topic "Adding a Data
Source" in the SQL Server 7.0 Books Online.

--
Alan Brewer
Technology Lead
SQL Server Documentation Team

 
 
 

Installing and configuring ODBC drivers

Post by Marc Rivai » Wed, 21 Jul 1999 04:00:00



>     Hi,

>         How can I install and configure ODBC DSN's without passing through
> the ODBC
>     window in the Control Panel? By functions or DOS, or executables, or
> INI's ... ??
>         I am coding a Windows installation program, and I need to install
> and configure
>     data sources ( SQL Server, text, and DBase ). I am using InstallShield.

>                     Please help me !

> Francky

The easiest way to cheat is to use Installshield's Repackager product
and configure the DSN's manually.  IS will create the code necessary to
configure the DSN.  You may need to edit this code a bit, but you will
have the basic syntax for creating DSN's through code.

Regards,
Marc.

 
 
 

Installing and configuring ODBC drivers

Post by Alsto » Thu, 22 Jul 1999 04:00:00




>>     Hi,

>>         How can I install and configure ODBC DSN's without passing
through
>> the ODBC
>>     window in the Control Panel? By functions or DOS, or executables, or
>> INI's ... ??
>>         I am coding a Windows installation program, and I need to install
>> and configure
>>     data sources ( SQL Server, text, and DBase ). I am using
InstallShield.

>>                     Please help me !

>> Francky
>The easiest way to cheat is to use Installshield's Repackager product
>and configure the DSN's manually.  IS will create the code necessary to
>configure the DSN.  You may need to edit this code a bit, but you will
>have the basic syntax for creating DSN's through code.

>Regards,
>Marc.

I don't have the Repackager product. Could anyone that has it please
tell me the syntax to use to create an SQL DSN through the _Drivers.ini ?

                                            Thanks,

                                                                Francky

 
 
 

Installing and configuring ODBC drivers

Post by Marc Rivai » Sat, 24 Jul 1999 04:00:00


I do not have any samples for the database types you specified.  Each
database driver will have different requirements that need to met.  What
version of IS are you running?
 
 
 

Installing and configuring ODBC drivers

Post by Franc » Sat, 24 Jul 1999 04:00:00


Marc Rivait a crit dans le message

Quote:>I do not have any samples for the database types you specified.  Each
>database driver will have different requirements that need to met.  What
>version of IS are you running?

5.1 Pro Build 147
 
 
 

Installing and configuring ODBC drivers

Post by Jim C. Burn » Sat, 24 Jul 1999 04:00:00


I am having the same issue trying to set the DSN properties
programmatically for Oracle ODBC and Oracle Lite ODBC using VB.  I
understand it can be done using C++ and SQLConfigDataSource (See
http://msdn.microsoft.com/library/sdkdoc/sql/6_odbcht_2.htm), but what
about VB and Oracle?

> Marc Rivait a crit dans le message

> >I do not have any samples for the database types you specified.  Each
> >database driver will have different requirements that need to met.  What
> >version of IS are you running?

> 5.1 Pro Build 147

 
 
 

Installing and configuring ODBC drivers

Post by Jim C. Burn » Tue, 27 Jul 1999 04:00:00


See articles in KB Q171146(Best), Q166392, Q147875 or for vb4 Q123008

>     Hi,

>         How can I install and configure ODBC DSN's without passing through
> the ODBC
>     window in the Control Panel? By functions or DOS, or executables, or
> INI's ... ??
>         I am coding a Windows installation program, and I need to install
> and configure
>     data sources ( SQL Server, text, and DBase ). I am using InstallShield.

>                     Please help me !

> Francky

 
 
 

Installing and configuring ODBC drivers

Post by Brent Hathcoc » Tue, 27 Jul 1999 04:00:00


Microsoft claims it can be done, but the code they sent me for VB does not
work.
I emailed them and called them, but they have not responeded.  I guess it
was another waste of a case number for support.

Maybe one day they will start sending documentation with their software
again.


>I am having the same issue trying to set the DSN properties
>programmatically for Oracle ODBC and Oracle Lite ODBC using VB.  I
>understand it can be done using C++ and SQLConfigDataSource (See
>http://msdn.microsoft.com/library/sdkdoc/sql/6_odbcht_2.htm), but what
>about VB and Oracle?


>> Marc Rivait a crit dans le message

>> >I do not have any samples for the database types you specified.  Each
>> >database driver will have different requirements that need to met.  What
>> >version of IS are you running?

>> 5.1 Pro Build 147

 
 
 

Installing and configuring ODBC drivers

Post by Marc Rivai » Wed, 28 Jul 1999 04:00:00



> Microsoft claims it can be done, but the code they sent me for VB does not
> work.
> I emailed them and called them, but they have not responeded.  I guess it
> was another waste of a case number for support.

> Maybe one day they will start sending documentation with their software
> again.


> >I am having the same issue trying to set the DSN properties
> >programmatically for Oracle ODBC and Oracle Lite ODBC using VB.  I
> >understand it can be done using C++ and SQLConfigDataSource (See
> >http://msdn.microsoft.com/library/sdkdoc/sql/6_odbcht_2.htm), but what
> >about VB and Oracle?


> >> Marc Rivait a crit dans le message

> >> >I do not have any samples for the database types you specified.  Each
> >> >database driver will have different requirements that need to met.  What
> >> >version of IS are you running?

> >> 5.1 Pro Build 147

I have enclosed a sample which adds a SQL Server datasource to the USER
DSN tab.  To add to the SYSTEM DSN, replace ODBC_ADD_DSN, with
ODBC_ADD_SYS_DSN.  

Hope this helps.

Marc.

Declare Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal
hwndParent As
Long, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal
lpszAttributes As String) As Long

Function PrepareDSN(ByVal strServerName As String, ByVal strDBName As
String,
ByVal strDSN As String, ByVal strDBUser As String, ByVal
strDBUserPassword As
String) As Boolean
On Error GoTo error_hdl
    Dim boolError As Boolean
    Dim strDSNString As String
    PrepareDSN = False

    strDSNString = Space(MAX_BUFFER_SIZE)
    strDSNString = ""
    strDSNString = strDSNString & "DSN=" & strDSN & Chr(0)
    strDSNString = strDSNString & "DESCRIPTION=" & "DSN Created
Dynamically On "
 & CStr(Now) & Chr(0)
    strDSNString = strDSNString & "Server=" & strServerName & Chr(0)
    strDSNString = strDSNString & "DATABASE=" & strDBName & Chr(0)
    strDSNString = strDSNString & Chr(0)

   If Not CBool(SQLConfigDataSource(0, _
                        ODBC_ADD_DSN, _
                        ODBCDriverDescription, _
                        strDSNString)) Then
        boolError = True
        Msgbox("Error in PrepareDSN::SQLConfigDataSource")
   End If

    If boolError Then
        Exit Function
    End If
    PrepareDSN = True
    Exit Function

error_hdl:
    msgbox "PrepareDSN_ErrHandler::" & Err.Description
End Function

 
 
 

Installing and configuring ODBC drivers

Post by Franc » Thu, 29 Jul 1999 04:00:00


    Is there a way to add a new DSN like this, but without using these
functions? ( I'm using InstallShield ). I tried adding the corresponding
entries in the System Registry, and in odbc.ini, but the new DSN does
not appear in the ODBC window... What did I forget?

                                                                    Francky


[ ... .... ... ]

Quote:>I have enclosed a sample which adds a SQL Server datasource to the USER
>DSN tab.  To add to the SYSTEM DSN, replace ODBC_ADD_DSN, with
>ODBC_ADD_SYS_DSN.

>Hope this helps.

>Marc.

>Declare Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal
>hwndParent As
>Long, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal
>lpszAttributes As String) As Long

>Function PrepareDSN(ByVal strServerName As String, ByVal strDBName As
>String,
>ByVal strDSN As String, ByVal strDBUser As String, ByVal
>strDBUserPassword As
>String) As Boolean
>On Error GoTo error_hdl
>    Dim boolError As Boolean
>    Dim strDSNString As String
>    PrepareDSN = False

>    strDSNString = Space(MAX_BUFFER_SIZE)
>    strDSNString = ""
>    strDSNString = strDSNString & "DSN=" & strDSN & Chr(0)
>    strDSNString = strDSNString & "DESCRIPTION=" & "DSN Created
>Dynamically On "
> & CStr(Now) & Chr(0)
>    strDSNString = strDSNString & "Server=" & strServerName & Chr(0)
>    strDSNString = strDSNString & "DATABASE=" & strDBName & Chr(0)
>    strDSNString = strDSNString & Chr(0)

>   If Not CBool(SQLConfigDataSource(0, _
>                        ODBC_ADD_DSN, _
>                        ODBCDriverDescription, _
>                        strDSNString)) Then
>        boolError = True
>        Msgbox("Error in PrepareDSN::SQLConfigDataSource")
>   End If

>    If boolError Then
>        Exit Function
>    End If
>    PrepareDSN = True
>    Exit Function

>error_hdl:
>    msgbox "PrepareDSN_ErrHandler::" & Err.Description
>End Function

 
 
 

Installing and configuring ODBC drivers

Post by Marc Rivai » Sat, 31 Jul 1999 04:00:00



>     Is there a way to add a new DSN like this, but without using these
> functions? ( I'm using InstallShield ). I tried adding the corresponding
> entries in the System Registry, and in odbc.ini, but the new DSN does
> not appear in the ODBC window... What did I forget?

>                                                                     Francky


> [ ... .... ... ]

> >I have enclosed a sample which adds a SQL Server datasource to the USER
> >DSN tab.  To add to the SYSTEM DSN, replace ODBC_ADD_DSN, with
> >ODBC_ADD_SYS_DSN.

> >Hope this helps.

> >Marc.

> >Declare Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal
> >hwndParent As
> >Long, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal
> >lpszAttributes As String) As Long

> >Function PrepareDSN(ByVal strServerName As String, ByVal strDBName As
> >String,
> >ByVal strDSN As String, ByVal strDBUser As String, ByVal
> >strDBUserPassword As
> >String) As Boolean
> >On Error GoTo error_hdl
> >    Dim boolError As Boolean
> >    Dim strDSNString As String
> >    PrepareDSN = False

> >    strDSNString = Space(MAX_BUFFER_SIZE)
> >    strDSNString = ""
> >    strDSNString = strDSNString & "DSN=" & strDSN & Chr(0)
> >    strDSNString = strDSNString & "DESCRIPTION=" & "DSN Created
> >Dynamically On "
> > & CStr(Now) & Chr(0)
> >    strDSNString = strDSNString & "Server=" & strServerName & Chr(0)
> >    strDSNString = strDSNString & "DATABASE=" & strDBName & Chr(0)
> >    strDSNString = strDSNString & Chr(0)

> >   If Not CBool(SQLConfigDataSource(0, _
> >                        ODBC_ADD_DSN, _
> >                        ODBCDriverDescription, _
> >                        strDSNString)) Then
> >        boolError = True
> >        Msgbox("Error in PrepareDSN::SQLConfigDataSource")
> >   End If

> >    If boolError Then
> >        Exit Function
> >    End If
> >    PrepareDSN = True
> >    Exit Function

> >error_hdl:
> >    msgbox "PrepareDSN_ErrHandler::" & Err.Description
> >End Function

Installshield does this by making registry entries.  This is tricky
business and you need to make sure you are doing all the correct
things.  I would not recommend this method unless you are 100% sure
about all the entries a specific DB driver requires.  As I mentioned
earlier, Repackager is a easy way to get IS5 to write this code for
you.  You should be able to download Repacker from their website
directly.

Regards,
Marc.