Create a DSN programmatically (SQLConfigDataSource)

  • Hi.

    i'm using this API : SQLConfigDataSource,

    found in ODBCCP32.DLL in order to create a System DSN programmatically. I'm under Delphi.

    Here is the description of this function:

    function SQLConfigDataSource (hwndParent : Integer; fRequest:Longint;lpszDriver : AnsiString;lpszAttributes : AnsiString): Longint;stdcall;external 'ODBCCP32.DLL' name 'SQLConfigDataSource';

    It works fine. But I want to use SQL authentification. So here is the value of lpszAttributes:

    Description=MyDesc

    Adress=localhost

    Database=MyDataBase

    Server=MyServer

    Trusted_Connection=No

    So I must provide a user name and a password in order to connect to the database. But I don't know the keywords to use.

    Do you know them? I've tried:

    UID=MyUid

    PWD=MyPassword

    but it doesn't work. Any ideas?

  • This was removed by the editor as SPAM

  • I am also interested in doing this.  I haven't had time to explore the issue as yet.

  • Could you try

    USER NAME=

    PASSWORD=

  • USER NAME= and PASSWORD= do not work for me.

    In fact, user name and password is not supported by SQL Server at all!!

    At http://www.sqlmonster.com/Uwe/Forum.aspx/sql-server-odbc/1335/Problems-setting-DSN-from-csharp-when

    Sue Hoegemeyer replied to a similar request: She says:

    "I don't think specifying uid and pwd with

    SQLConfigDataSource API is supported with SQL Server. You

    can find the supported attributes for the SQL Server ODNBC

    driver at:

    http://msdn.microsoft.com/library/en-us/odbcsql/od_odbc_c_99yd.asp

    You can specify to use a trusted connection. But as noted in

    the docs, if you don't specify a trusted connection then the

    User name and password must be provided for each connection.

    "

    Regards

    Willem

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply