Creating DSN don't work

From: eshipman (mr_delphi_developer_at_yahoo!!!.com)
Date: 03/10/05


Date: Thu, 10 Mar 2005 11:17:04 -0600

I have this code to create a DSN. It creates the DSN in ODBC.ini but
I can not get it configured correctly. When I open ODBC Admin, the
DSn has the wrong server and login info.

What am I doing wrong?

  if SQLRemoveDSNFromIni('TA') then
  begin
    SQLWriteDSNToIni('TA', 'SQL Server');
    SqlConfigDataSource(0,
                        ODBC_CONFIG_DSN,
                        PChar('SQL Server'),
                        Pchar('DSN=TA;'+
                              'Server=xxx.xxx.xxx.xxx;'+ // server IP
                              'Database=catalogname;'+
                              'Uid=dbuser;'+
                              'Pwd=dbpwd;'+
                              'Trusted_Connection=yes;'));
    ADOConnection1.ConnectionString := 'DSN=TA';
    ADOConnection1.Open;
    // Errors out with this error:
    // [Microsoft][OBC SQL Server Driver][DBNETLIB]SQL Server does not
    // exist or access denied
  end
  else
  begin
    ShowMessage('error');
  end;



Relevant Pages

  • Re: Failed Connection to SQL Srvr 2005
    ... why are you creating a DSN at all and why are you using ODBC? ... Understand that SQL ... Server has been configured for some time now to be invisible to the network ... (connections work). ...
    (microsoft.public.sqlserver.connect)
  • Re: Alternative to using DSN to connect to database
    ... As for SQL Server could be moved to other computer than the original ... Note, even you use DSN, you have to change server name in the DSN ... You should always use SQL Server's native .NET provider, ... >> if you want to change the connection string dynamically you can put the ...
    (microsoft.public.dotnet.framework.adonet)
  • re: Stop me before I use DSN again!
    ... >site to my home server that has no such DSN defined. ... >from a query that uses a linked table, ... Set cnNwind= Server.CreateObject ...
    (microsoft.public.frontpage.client)
  • Create a DSN programmatically with network options
    ... I would like to create a brand new system DSN, programmatically, ... Relying on this single registry entry is not enough since it only ... least for SQL Server). ... networking options cannot be set ...
    (microsoft.public.sqlserver.odbc)
  • Re: Trying to get DSN notifications with delayed/failed mail
    ... SMTP Server. ... alerting mail originators if their app has generated badmail, ... You will never get a DSN if the From: ...
    (microsoft.public.inetserver.iis.smtp_nntp)