• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2753
  • Last Modified:

Delphi 2010 dbxConnection to MS SQL Server DB using Ini Files ?

Thanks to the EE "ebob42" i have solved one problem.

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Database/Q_25890299.html

Now i am trying to further this question by using dbExpress ini files to make a connection.

I would like to create a test delphi application that can connect to a MS SQL Server 2005 database on a MS Server 2009 OS.

Here are my INi FIle entries:

dbxconnections.ini

[VPUCDS_VPN_SE01]
DriverName=MSSQL
HostName=SEAVALUPAY01
DataBase=vpucds02
User_Name=sysdba
Password=masterkey
BlobSize=-1
ErrorResourceFile=
LocaleCode=0000
MSSQL TransIsolation=ReadCommited
OS Authentication=False

dbxdrivers.ini

[MSSQL]
GetDriverFunc=getSQLDriverSQLServer
LibraryName=C:\Test\dbxmss.dll
VendorLib=C:\Test\sqlncli10.dll
HostName=SEAVALUPAY01
Database=vpucds02
User_Name=sysdba      
Password=masterkey
BlobSize=-1
ErrorResourceFile=
LocaleCode=0000
MSSQL TransIsolation=ReadCommited
OS Authentication=False


The old working code (thanks to: ebob42 ) which makes a connection without Ini files

procedure TMainForm.Button1Click(Sender: TObject);
var
  Conn: TSQLConnection;
begin
  Conn := TSQLConnection.Create(nil);
  Conn.DriverName:= 'MSSQL';
  Conn.LoadParamsOnConnect := False;
  Conn.LibraryName:= 'DBXMSS.DLL';
  Conn.VendorLib:= 'SQLNCLI10.DLL';
  Conn.GetDriverFunc:= 'getSQLDriverMSSQL';
  Conn.Params.Add('User_Name=sa');
  Conn.Params.Add('Password=********');
  Conn.Params.Add('Database=weblog');
  Conn.Params.Add('HostName=192.168.1.7');
  Conn.LoginPrompt:= False;
  try
    Conn.Connected:= True;
    if Conn.Connected then
      ShowMessage('Connected!')
    else
      ShowMessage('NOT Connected!')
  finally
    Conn.Free;
  end;
end;

I need new code which would make the connection with ini files.  I have tried a number of variations.


procedure TMainForm.Button1Click(Sender: TObject);
var
  Conn: TSQLConnection;
begin
  Conn := TSQLConnection.Create(nil);
  Conn.ConnectionName:= 'VPUCDS_VPN_SE01';
  Conn.LoadParamsOnConnect := True;
  Conn.LoginPrompt:= True;
  try
    Conn.Connected:= True;
    if Conn.Connected then
      ShowMessage('Connected!')
    else
      ShowMessage('NOT Connected!')
  finally
    Conn.Free;
  end;
end;


thankx
0
DelphiRulez
Asked:
DelphiRulez
  • 3
  • 2
1 Solution
 
ebob42Commented:
What is the problem with the code you're trying? You get "Not Connected"?

Where do you place the .ini files?

Try to remove the C:\Test\ parts in the DLL paths in the dbxdrivers.ini file, that's not needed.
0
 
DelphiRulezAuthor Commented:
Hi Bob,

I tried both with and with out the paths in the ini files.  Yes, the ini files reside with the executable.
All the DLL's are there as when the test executable was working with the code without the ini files.

I get a "dbxmss.dll library missing - getSQLDriverSQLServer driver func"

Shane
0
 
DelphiRulezAuthor Commented:
Ha, never mind, i figured it out

i had " getSQLDriverSQLServer" as the driver in my ini file rather than  "getSQLDriverMSSQL"

thanks for pushing me though
0
 
ebob42Commented:
Is the application a normal executable? Or a web application? (especially if it's an ISAPI DLL, the working directory may be different, so it may not be able to find the dbxmss.dll in the same directory as the project itself).

Could you - for a little test - copy the dbxmss.dll to the Windows or Windows\System32 directory and see if that makes the application find it? (to confirm that it's a path issue).
0
 
DelphiRulezAuthor Commented:
well, it is actually just a test executable, however, I took the code we got working earlier (without ini files) and punched it into my webservice and it also worked.

Now, i got the test executable to work with the ini files, and im going to punch that into the web service and make sure it works

I curently have a webservice call - called"
function ConnectToDB: Boolean;stdcall;

this just returns a true if connected to DB or false if not.


I am now gonna create a function in my service where you pass the alias

function ConnectToDB(dbAlias: AnsiString): Boolean;stdcall;

and use the ini files

<smile>


Im just precticing and getting prepared to write some serious DB calls against our DB

shane
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now