Recent

Author Topic: is there anybody can connect to ms sql server from lazarus?  (Read 32213 times)

halityilmaz

  • Newbie
  • Posts: 3
is there anybody can connect to ms sql server from lazarus?
« on: August 25, 2010, 12:51:24 pm »
hi all,
i have a linux installed machine and want to develop a program working with mssql server. i did it with delphi and worked fine. when i try to connect to mssql from linux on lazarus ide unfortunately i can do nothing;

i tried zeoslib and sqlconnector on lazarus.

on zeoslib i had an error about a dll file, and when i tried the sql connector i had a problem with connectortype.

so is there anybody who can connected to mssql under linux on lazarus ide with any kind of companent?

thank you.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12121
  • FPC developer.
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #1 on: August 25, 2010, 03:11:34 pm »
To my best knowledge, connection is only possible over odbc, since ADO is not supported by FPC/Lazarus.

See e.g. my unanswered question about this subject in the zeos forum: http://zeos.firmos.at/viewtopic.php?t=2077

Lacak2

  • Guest
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #2 on: August 26, 2010, 07:14:13 am »

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #3 on: October 16, 2010, 05:18:37 pm »
Use component palette SQLdb
select TSQLConnector [for your msSQL] and not other TSQLs
select also TSQLquery, TSQLtransaction
if you want to use Data Controls for datasource?  select palette Data Access, then Tdatasource.

Just that to build a fine database program. :D

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #4 on: October 17, 2010, 02:57:14 pm »
See this post.
Updated oct 21 2010 with add_delete_update_print
http://forum.lazarus.freepascal.org/index.php/topic,10811.0.html
 :D
« Last Edit: October 19, 2010, 07:00:48 pm by xenablaise »

fbdioan

  • Guest
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #5 on: November 11, 2010, 04:54:00 pm »
Search in the free pascal tracker for a tmssqlconnection component which AFAIR is in beta2 waiting for inclusion.

AFAIR, it's from lacak2.

EDIT: Founded it's there http://mantis.freepascal.org/view.php?id=17303, didn't test it, but it looks promising ...
« Last Edit: November 11, 2010, 04:55:37 pm by fbdioan »

Mario13

  • Newbie
  • Posts: 5
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #6 on: October 08, 2012, 07:58:50 pm »
I was able to connect to MSSQL server 2000 with Lazarus using Zeos and using the new TMSSQLConnection (SQLdb):

- First of all, for FreeTDS you have to be sure that the server is listening TCP/IP on port 1433 (o whatever you defined), you can test it with command netstat -an on the server prompt.

- For  TMSSQLConnection you need FPC 2.6.1 or later, and Lazarus 1.0 or later (that component appears in the SQLdb palette).

- Windows client Native: With SQLdb the default client library points to FreeTDS dblib.dll, but I could not find such a compatible library (the ones provided with Zeos doesn't work). However, if you edit file dblib.pas (from FPC) you can enable the native Microsoft library ntwdblib.dll.
With ZEOS you can use TZConnection with protocol mssql, in this case, you must have the client library ntwdblib.dll installed. This dll works with both Named Pipes and TCP/IP connections. For Delphi (not Lazarus) it appears to be another Zeos protocol ado to be used with SQL server 2005 or later. However, note that using source code with protocol mssql or ado is not platform independient.

- Windows client FreeTDS: With SQLdb you have to provide file dblib.dll (I couldn't find one). With ZEOS you can use TZConnection with protocol FreeTDS_MsSQL-2000, in this case you must put msdblibr.dll in the same folder of your exe (which also requires msvcrt100.dll). This dll is supplied in the lib folder of Zeos, with 32 and 64 bit versions. There is only support for TCP/IP fixed port connections (no Named Pipes or dynamic ports). Also, there are other three protocol variants for different server versions.

- Wine on Linux client: Only the Zeos FreeTDS protocols and dll works (and only with TCP/IP on fixed port, no Named Pipes in Wine, no Named Pipes in FreeTDS).

- Linux Client: With SQLdb it works when FreeTDS is installed and configured (with package libsybd5). With ZEOS you can use TZConnection with protocol FreeTDS_MsSQL-2000, in this case you must have installed the FreeTDS libraries (for example in Debian the packages freetds-bin and libsybd5). For this to work you have to modify ZPlainDbLibDriver.pas in th line 68: FREETDS_LINUX_DLL_LOCATION = 'libsybdb.so';
« Last Edit: October 08, 2012, 08:15:21 pm by Mario13 »

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #7 on: October 09, 2012, 08:59:14 am »
Quote
Windows client FreeTDS: With SQLdb you have to provide file dblib.dll (I couldn't find one).
the 32 and 64 bit dll's can be found here: ftp://ftp.freepascal.org/fpc/contrib/windows/

EgonHugeist

  • Jr. Member
  • **
  • Posts: 78
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #8 on: October 22, 2012, 10:43:43 pm »
Hi all,

i managed some encoding stuff for Zeos and MsSQL. You can sucessfully connect with the FreeTDS protocol we have. Remaning was now to display and upate national chars.

I've implemented the LConEncoding unit of Lazarus with a define (uncomment WITH_LCONVENCODING define in file ZeosLazarus.inc and be sure this unit can be found from the compiler). Also is that possible with MsWindows (no Wince). Remaining is the libiconv implementation.

Things Zeos must know before:

Set TZConnection.AutoEncodeStrings := True; (i've renamed PreprepareSQL to clearify the purpose of that property)
Now you can see the supported client-characterset in TZConnection.ClientCodePage. Choose the windows related codepage the server uses.
Also must the new TZConnection.ControlsCodePage property set to cCP_UTF8(default for FPC).

Now Zeos knows which char conversations must have been done.

You can now use Zeos without changing your custom or some extra encoding lines.

Btw. this works for all non UTF8 charactersets of all DBMRS too if the nessecary functions are available. (LConEncoding)

Best regards, Michael

Edit: Rev1927 \testing(SVN)
Question: Is there sombody who can compile FreeTDS for *nix and OSX systems? Please contact EgonHugeist in the Zeos-Forum.
« Last Edit: October 22, 2012, 10:51:33 pm by EgonHugeist »

woec

  • Newbie
  • Posts: 2
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #9 on: November 20, 2012, 11:46:29 am »
Hi,

using activation of define LCONVENCODING in ZeosLazarus.inc creates a side effect in my installation:
object completion does not work any more in the lazarus editor: if I type the name of a defined object up to the '.' - no listing of available properties/procedures occur. If I then press Ctrl-space (twice), the editor opens ZeosLazarus.inc and sets the cursor to the line with the define "WITH_LCONVENCODING" (which was uncommented before to get the national characters to work)
(national character translation works, if directive is uncommented)

If I return to outcommented define of LCONVENCODING, completion works again as it is expected.

My environment: WinXP, Lazarus 1.0.2 (fpc 2.6.0)

Any idea, how to solve this?

regards,
woec

EgonHugeist

  • Jr. Member
  • **
  • Posts: 78
Re: is there anybody can connect to ms sql server from lazarus?
« Reply #10 on: November 20, 2012, 02:00:02 pm »
woec,

Currently i've no idea what exactly the issue is, you're talking about. I personally did never test it on non windows plattforms but others did this successfully. An i can't tell you if this can be handled otherwice.

All i did was mainly to solve encoding issues lazarus + MsSQL have. I made the sime possible for FPC2.7.1 which has a BuildIn-WideString-Manager. In this case you don't need the LCL spezial unit any more and the FPC2.7.1 (i like it!) is able to du such conversations with equal settings:

TZConnection.ControlsCodePage = cCP_UTF8;
TZConnection.AutoEncodeStrings = True;
TZConnection.ClientCodePage = 'WINxxxx';
\testing (SVN) since R2009 i think + FPC2.7.x

So zeos is able to support such issues much better. This WITH_LCONVENCODING define is my current workaround to get such encoding issues solved which MsSQL (not UTF8-Charset) and Lazarus (assumes all strings are UTF8) do produce and  if no LibIconv(speed decrease) or an BuildIn-WideString-Manager(FPC2.6Down) is used.

I propose you open a more detailed Thread in the Zeos-Forum which is propably made to handle Zeos-Issues.  ;)

Regards, Michael

 

TinyPortal © 2005-2018