Recent

Author Topic: dblib.dll error - MS SQL Express  (Read 6297 times)

alpine

  • Hero Member
  • *****
  • Posts: 1412
Re: dblib.dll error - MS SQL Express
« Reply #15 on: April 27, 2024, 04:14:25 pm »
Quote
Or are there any other properties that I have to set - PortNumber or something else (I believe that the server listening on default 1433)

You can check into the Configuration Manager (as the attached picture in reply #10), the "IP Addresses" tab.

You can see the output of:
Code: [Select]
netstat -anLook for a listening socket on 0.0.0.0:1433

Again: Are you sure you have the appropriate MSVCRT installed as is it shown on the second attachment? (working test proj on my laptop)

Attached is the version info of the libiconv2.dll. Unfortunately dblib.dll doesn't have such info.
« Last Edit: April 27, 2024, 05:04:01 pm by alpine »
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

ap3000

  • New Member
  • *
  • Posts: 36
Re: dblib.dll error - MS SQL Express
« Reply #16 on: April 27, 2024, 08:41:43 pm »
Thanks, Alpine

Indeed, I don't get something listening on port 1433 when I do a netstat -an. When I run Dependency Walker I see MSVCR80.DLL but I also see some errors, but I have no clue what they mean. I included the dblib.dwi file from Dependency Walker. I hope someone can make something of it.

I also installed SQL Express in a new Virtual Machine and there I got the same results - No listener on port 1433 and the same error messages in Dependency Walker.

Oeps the dblib.dwi file is to big, so her alink: https://www.dropbox.com/scl/fi/pu2e6hnlg5fs827kg9fc6/dblib.dwi?rlkey=cmvfft69wkftddj5s51j5hfo7&st=zngkkvlh&dl=0
Anders Pedersen

alpine

  • Hero Member
  • *****
  • Posts: 1412
Re: dblib.dll error - MS SQL Express
« Reply #17 on: April 27, 2024, 09:01:21 pm »
Check the attached picture.
TCP Dynamic Ports must be empty.
TCP Port must be 1433 (or other, as long as you specify it correctly into the client connection)

You must also specify it as an exception into the firewall. Hope you won't make it open in Internet, you'll get immediately flooded then.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

ap3000

  • New Member
  • *
  • Posts: 36
Re: dblib.dll error - MS SQL Express
« Reply #18 on: April 27, 2024, 09:29:26 pm »
No - still same result  >:(

But I don't understand why my C# console app is working and the Pascal doesn't.

I then think that the SQL server is OK. But that of the TMSSQLConnection needs some configuration that I don't know about or indeed that the SQL client driver need some more dll's
Anders Pedersen

alpine

  • Hero Member
  • *****
  • Posts: 1412
Re: dblib.dll error - MS SQL Express
« Reply #19 on: April 27, 2024, 09:43:40 pm »
Did you restart the server after changing the configuration?

You have to direct your effort into TCP/IP Server configuration until netstat -an shows that there is a service listening at 0.0.0.0:1433.

Until then all your connection attempts will fail.
 

"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

ap3000

  • New Member
  • *
  • Posts: 36
Re: dblib.dll error - MS SQL Express
« Reply #20 on: April 27, 2024, 11:25:01 pm »
Yes, I restarted the server and now I get a service listening on 0.0.0.0:1433. But still the error:

Error: TMSSQLConnection : Error 20009 :
Unable to connect: Adaptive Server is unavailable or does not exist (DESKTOP-N1EKOSK)

Anders Pedersen

alpine

  • Hero Member
  • *****
  • Posts: 1412
Re: dblib.dll error - MS SQL Express
« Reply #21 on: April 27, 2024, 11:31:10 pm »
Try to use an IP address instead of a name. In case of the local machine use 127.0.0.1 (local loopback).
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Zvoni

  • Hero Member
  • *****
  • Posts: 3226
Re: dblib.dll error - MS SQL Express
« Reply #22 on: April 28, 2024, 08:09:02 am »
Has anyone ckecked 32-bit vs. 64 bit?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

ap3000

  • New Member
  • *
  • Posts: 36
Re: dblib.dll error - MS SQL Express
« Reply #23 on: April 28, 2024, 12:35:34 pm »
Yes, I have tried IP-Adress, 127.0.0.1, 0.0.0.0 and the IP-Adress of the computer itself.
And I have tried all kinds of combinations of 32 vs 64-bit. I have tried older versions of dblib.dll.

I start to ask myself if I'm the only one who wants to use MS SQL Express in combination with FreePascal/Lazarus.

Anders Pedersen

alpine

  • Hero Member
  • *****
  • Posts: 1412
Re: dblib.dll error - MS SQL Express
« Reply #24 on: April 28, 2024, 01:04:02 pm »
Yes, I have tried IP-Adress, 127.0.0.1, 0.0.0.0 and the IP-Adress of the computer itself.
And I have tried all kinds of combinations of 32 vs 64-bit. I have tried older versions of dblib.dll.

I start to ask myself if I'm the only one who wants to use MS SQL Express in combination with FreePascal/Lazarus.
I'm using it, it is not because I want it, but I must to.

My Lazarus apps are 32-bit. I have found the exact dblib.dll+libiconv2.dll that works for me, all MSSQLs are installed as default instances (please, consult M$ site for the meaning of 'default instance').

The installation troubles that I usually have are:
Correct version of MSVCRT missing.
MSSQL was installed with the default collation, (then masterdb must be rebuilt with the exact collation needed).
Firewall doesn't allow client connections.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

ap3000

  • New Member
  • *
  • Posts: 36
Re: dblib.dll error - MS SQL Express
« Reply #25 on: April 28, 2024, 10:47:22 pm »
Hi Alpine

Yes, MS SQL Express is installed as the default instance and I have the 0.0.0.0:1433 from netstat -an.

But I see a difference between your and my screenshot of the Dependency Walker. In my screenshot some of the Icons are red, yours is not. Could there be a reason?
You write "I have found the exact dblib.dll+libiconv2.dll". What are those files and where can I get them?

I'm not sure how I can find out if I have the Correct version of MSVCRT?
Anders Pedersen

alpine

  • Hero Member
  • *****
  • Posts: 1412
Re: dblib.dll error - MS SQL Express
« Reply #26 on: April 29, 2024, 12:11:49 am »
Hi Alpine

Yes, MS SQL Express is installed as the default instance and I have the 0.0.0.0:1433 from netstat -an.

But I see a difference between your and my screenshot of the Dependency Walker. In my screenshot some of the Icons are red, yours is not. Could there be a reason?
Not sure. As I said, mine is 32-bit. Yours - 64. I don't think that is the main problem, but you must always use libraries with the same bitness as your app. Otherwise you'll get the error as in the original post.
 
You write "I have found the exact dblib.dll+libiconv2.dll". What are those files and where can I get them?
http://downloads.freepascal.org/fpc/contrib/windows/ (your original post)
There are several versions in zip files. Into the zip files are all dlls for both 32 and 64 bit.

I'm not sure how I can find out if I have the Correct version of MSVCRT?
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
(show more link)

I believe you have it, since in the dependency walker it is not red (MSVCR80.DLL). Of course, you must install for the same bitness (32 or 64) as your app and your dblib.dll, libicon2.dll.

I'm a little concerned about:
Code: Pascal  [Select][+][-]
  1. AConnection.HostName := 'localhost\SQLEXPRESS';

I think it should be just:
Code: Pascal  [Select][+][-]
  1. AConnection.HostName := 'localhost';
for the default instance.

My (default) instance name is MSSQLSERVER (seen in my reply #17). Yours: SQLEXPRESS (in your reply #10).

Quote from https://learn.microsoft.com/en-us/sql/sql-server/install/instance-configuration?view=sql-server-ver16:
Quote
An instance is either the default instance or a named instance. The default instance name is MSSQLSERVER. The default name doesn't require a client to specify the name of the instance to make a connection. A named instance is determined by the user during Setup. You can install SQL Server as a named instance without installing the default instance first. Only one installation of SQL Server, no matter the version, can be the default instance at one time.

I'm guessing that might be a problem, MS SQL is full of such a nasty particularities.



« Last Edit: April 29, 2024, 12:21:32 am by alpine »
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

ap3000

  • New Member
  • *
  • Posts: 36
Re: dblib.dll error - MS SQL Express
« Reply #27 on: April 30, 2024, 09:24:54 pm »
Problem solved  :D

Hi Alpine, You nailed it - HostName needs to be only "localhost" without the instance name of the server. I can even use the name of the computer, the ip-address and 127.0.0.1
 I feel a little bit stupid I had tested it with only localhost, but that was maybe when I had the wrong dblib.dll.

I want to give a big THANK YOU for your support and your patience with me  :)
Anders Pedersen

 

TinyPortal © 2005-2018