SQLdb: TMSSQLConnection: using Instance name in Host

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
Hi,

Is possible to use "instance name" in host connection like bellow?
server001\instanceABC

I'm using FPC 2.6.2

Thanks,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Michael Van Canneyt


On Fri, 21 Jun 2013, Marcos Douglas wrote:

> Hi,
>
> Is possible to use "instance name" in host connection like bellow?
> server001\instanceABC

Small linguistic remark: it is below, not bellow :-)

To bellow is something quite different :)

That said: it should be possible, SQLDB passes the string on as-is.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
In reply to this post by Marcos Douglas B. Santos
On Fri, Jun 21, 2013 at 10:38 AM, Marcos Douglas <[hidden email]> wrote:
> Hi,
>
> Is possible to use "instance name" in host connection like bellow?
> server001\instanceABC
>
> I'm using FPC 2.6.2
>
> Thanks,
> Marcos Douglas

The error is:
Error 20002
Adaptive Server connection failed

I found some links, but I do not know how FreeTDS is used in FPC:
http://stackoverflow.com/questions/7590944/freetds-connection-problems-on-linux
http://stackoverflow.com/questions/10121212/cannot-connect-to-sql-server-database-using-pymssql-but-can-connect-using-underl

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Michael Van Canneyt


On Fri, 21 Jun 2013, Marcos Douglas wrote:

> On Fri, Jun 21, 2013 at 10:38 AM, Marcos Douglas <[hidden email]> wrote:
>> Hi,
>>
>> Is possible to use "instance name" in host connection like bellow?
>> server001\instanceABC
>>
>> I'm using FPC 2.6.2
>>
>> Thanks,
>> Marcos Douglas
>
> The error is:
> Error 20002
> Adaptive Server connection failed

Try adding it in databasename.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
In reply to this post by Michael Van Canneyt
On Fri, Jun 21, 2013 at 11:10 AM, Michael Van Canneyt
<[hidden email]> wrote:

>
>
> On Fri, 21 Jun 2013, Marcos Douglas wrote:
>
>> Hi,
>>
>> Is possible to use "instance name" in host connection like bellow?
>> server001\instanceABC
>
>
> Small linguistic remark: it is below, not bellow :-)
>
> To bellow is something quite different :)

Ops! Sorry!  :)

> That said: it should be possible, SQLDB passes the string on as-is.
>

This link talk about UDP protocol request to know what port is used:
http://www.mssqltips.com/sqlservertip/2661/how-to-connect-to-a-sql-server-named-instance/

I do not know if the drive do that...

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
In reply to this post by Michael Van Canneyt
On Fri, Jun 21, 2013 at 11:16 AM, Michael Van Canneyt
<[hidden email]> wrote:

>
>
> On Fri, 21 Jun 2013, Marcos Douglas wrote:
>
>> On Fri, Jun 21, 2013 at 10:38 AM, Marcos Douglas <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> Is possible to use "instance name" in host connection like bellow?
>>> server001\instanceABC
>>>
>>> I'm using FPC 2.6.2
>>>
>>> Thanks,
>>> Marcos Douglas
>>
>>
>> The error is:
>> Error 20002
>> Adaptive Server connection failed
>
>
> Try adding it in databasename.

But this is a hostname info, not database name. (?)

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Ludo Brands
In reply to this post by Marcos Douglas B. Santos
On 06/21/2013 04:14 PM, Marcos Douglas wrote:

> On Fri, Jun 21, 2013 at 10:38 AM, Marcos Douglas <[hidden email]> wrote:
>> Hi,
>>
>> Is possible to use "instance name" in host connection like bellow?
>> server001\instanceABC
>>
>> I'm using FPC 2.6.2
>>
>> Thanks,
>> Marcos Douglas
>
> The error is:
> Error 20002
> Adaptive Server connection failed
>

This should work. Can you connect with another client using the
instance? tsql?

I have encountered this problem with sql server when the SQL Server
Browser service is not started. The name is a bit confusing because it
is needed for clients to be able to contact with a named instance. If
this service is down, you can only connect with a port number. It
listens normally on port port 1434 and responds with the port number for
the instance.

Another option is to define the connection in freetds.conf. Something like
[myserver001]
    host = server001
    instance = instanceABC
    tds version = 8.0

Don't specify a port when you specify an instance. They are mutually
exclusive.

Ludo
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
On Fri, Jun 21, 2013 at 2:25 PM, Ludo Brands <[hidden email]> wrote:

> On 06/21/2013 04:14 PM, Marcos Douglas wrote:
>> On Fri, Jun 21, 2013 at 10:38 AM, Marcos Douglas <[hidden email]> wrote:
>>> Hi,
>>>
>>> Is possible to use "instance name" in host connection like bellow?
>>> server001\instanceABC
>>>
>>> I'm using FPC 2.6.2
>>>
>>> Thanks,
>>> Marcos Douglas
>>
>> The error is:
>> Error 20002
>> Adaptive Server connection failed
>>
>
> This should work. Can you connect with another client using the
> instance? tsql?
>
> I have encountered this problem with sql server when the SQL Server
> Browser service is not started. The name is a bit confusing because it
> is needed for clients to be able to contact with a named instance. If
> this service is down, you can only connect with a port number. It
> listens normally on port port 1434 and responds with the port number for
> the instance.
>
> Another option is to define the connection in freetds.conf. Something like
> [myserver001]
>     host = server001
>     instance = instanceABC
>     tds version = 8.0
>

I can specify the version? I'm using MSSQL 2008
The freetds.conf file has priority to set configurations even if the
mssqlconn has this?

  dbsetlversion(FDBLogin, DBVERSION[IsSybase]);

> Don't specify a port when you specify an instance. They are mutually
> exclusive.

Ok.


Worked but I have another problem:
To connect in DB of my client I need to pass the Application Name parameter.
I tried to use Params property but didn't worked so, I changed the mssqlconn:

  dbsetlname(FDBLogin, PChar('MyApp'), DBSETAPP);

But didn't worked... Can you help me?

Thanks,
Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Ludo Brands
On 06/21/2013 08:01 PM, Marcos Douglas wrote:

> Worked but I have another problem:
> To connect in DB of my client I need to pass the Application Name parameter.
> I tried to use Params property but didn't worked so, I changed the mssqlconn:
>
>   dbsetlname(FDBLogin, PChar('MyApp'), DBSETAPP);
>
> But didn't worked... Can you help me?


Params won't work. There are only a few keywords supported by sqldb.

dbsetlname(FDBLogin, PChar('MyApp'), DBSETAPP); should work. Did you put
it before the call to dbopen?

Ah, just found out that DBSETAPP is wrongly defined for FreeTDS.
It should be 5 instead of 4 according to include/sybdb.h.
Try dbsetlname(FDBLogin, PChar('MyApp'), 5);

Ludo

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
On Fri, Jun 21, 2013 at 3:59 PM, Ludo Brands <[hidden email]> wrote:

> On 06/21/2013 08:01 PM, Marcos Douglas wrote:
>
>> Worked but I have another problem:
>> To connect in DB of my client I need to pass the Application Name parameter.
>> I tried to use Params property but didn't worked so, I changed the mssqlconn:
>>
>>   dbsetlname(FDBLogin, PChar('MyApp'), DBSETAPP);
>>
>> But didn't worked... Can you help me?
>
>
> Params won't work. There are only a few keywords supported by sqldb.
>
> dbsetlname(FDBLogin, PChar('MyApp'), DBSETAPP); should work. Did you put
> it before the call to dbopen?
>
> Ah, just found out that DBSETAPP is wrongly defined for FreeTDS.
> It should be 5 instead of 4 according to include/sybdb.h.
> Try dbsetlname(FDBLogin, PChar('MyApp'), 5);

Aff! I would post before you!  :)

You're right I used DBSETID:
  dbsetlname(FDBLogin, PChar('MyApp'), DBSETID);

You think is better use 5 instead DBSETID? The source will change?

Thank you very much!

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
On Fri, Jun 21, 2013 at 4:08 PM, Marcos Douglas <[hidden email]> wrote:

> On Fri, Jun 21, 2013 at 3:59 PM, Ludo Brands <[hidden email]> wrote:
>> On 06/21/2013 08:01 PM, Marcos Douglas wrote:
>>
>>> Worked but I have another problem:
>>> To connect in DB of my client I need to pass the Application Name parameter.
>>> I tried to use Params property but didn't worked so, I changed the mssqlconn:
>>>
>>>   dbsetlname(FDBLogin, PChar('MyApp'), DBSETAPP);
>>>
>>> But didn't worked... Can you help me?
>>
>>
>> Params won't work. There are only a few keywords supported by sqldb.
>>
>> dbsetlname(FDBLogin, PChar('MyApp'), DBSETAPP); should work. Did you put
>> it before the call to dbopen?
>>
>> Ah, just found out that DBSETAPP is wrongly defined for FreeTDS.
>> It should be 5 instead of 4 according to include/sybdb.h.
>> Try dbsetlname(FDBLogin, PChar('MyApp'), 5);
>
> Aff! I would post before you!  :)
>
> You're right I used DBSETID:
>   dbsetlname(FDBLogin, PChar('MyApp'), DBSETID);
>
> You think is better use 5 instead DBSETID? The source will change?
>
> Thank you very much!

Ah, you want a patch? -- should check the Params if there is the
'Application Name' parameter.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Ludo Brands
On 06/21/2013 09:12 PM, Marcos Douglas wrote:

> On Fri, Jun 21, 2013 at 4:08 PM, Marcos Douglas <[hidden email]> wrote:
>> On Fri, Jun 21, 2013 at 3:59 PM, Ludo Brands <[hidden email]> wrote:
>>> Ah, just found out that DBSETAPP is wrongly defined for FreeTDS.
>>> It should be 5 instead of 4 according to include/sybdb.h.
>>> Try dbsetlname(FDBLogin, PChar('MyApp'), 5);
>>
>> Aff! I would post before you!  :)
>>
>> You're right I used DBSETID:
>>   dbsetlname(FDBLogin, PChar('MyApp'), DBSETID);
>>
>> You think is better use 5 instead DBSETID? The source will change?
>>
>> Thank you very much!
>
> Ah, you want a patch? -- should check the Params if there is the
> 'Application Name' parameter.
>

Can you confirm it works with dbsetlname(FDBLogin, PChar('MyApp'), 5) ?
If that is the case I'll make a patch for dblib.pp and will add an
application parameter to mssqlconn.

Ludo
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
On Sat, Jun 22, 2013 at 4:35 AM, Ludo Brands <[hidden email]> wrote:

> On 06/21/2013 09:12 PM, Marcos Douglas wrote:
>> On Fri, Jun 21, 2013 at 4:08 PM, Marcos Douglas <[hidden email]> wrote:
>>> On Fri, Jun 21, 2013 at 3:59 PM, Ludo Brands <[hidden email]> wrote:
>>>> Ah, just found out that DBSETAPP is wrongly defined for FreeTDS.
>>>> It should be 5 instead of 4 according to include/sybdb.h.
>>>> Try dbsetlname(FDBLogin, PChar('MyApp'), 5);
>>>
>>> Aff! I would post before you!  :)
>>>
>>> You're right I used DBSETID:
>>>   dbsetlname(FDBLogin, PChar('MyApp'), DBSETID);
>>>
>>> You think is better use 5 instead DBSETID? The source will change?
>>>
>>> Thank you very much!
>>
>> Ah, you want a patch? -- should check the Params if there is the
>> 'Application Name' parameter.
>>
>
> Can you confirm it works with dbsetlname(FDBLogin, PChar('MyApp'), 5) ?
> If that is the case I'll make a patch for dblib.pp and will add an
> application parameter to mssqlconn.

Yes, I confirm. The ApplicationName was shown in Profiler tool.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Ludo Brands
On 06/22/2013 03:20 PM, Marcos Douglas wrote:
> On Sat, Jun 22, 2013 at 4:35 AM, Ludo Brands <[hidden email]> wrote:
>> Can you confirm it works with dbsetlname(FDBLogin, PChar('MyApp'), 5) ?
>> If that is the case I'll make a patch for dblib.pp and will add an
>> application parameter to mssqlconn.
>
> Yes, I confirm. The ApplicationName was shown in Profiler tool.

Patch in http://bugs.freepascal.org/view.php?id=24635. New parameter is
"ApplicationName".

Ludo
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Michael Van Canneyt


On Sat, 22 Jun 2013, Ludo Brands wrote:

> On 06/22/2013 03:20 PM, Marcos Douglas wrote:
>> On Sat, Jun 22, 2013 at 4:35 AM, Ludo Brands <[hidden email]> wrote:
>>> Can you confirm it works with dbsetlname(FDBLogin, PChar('MyApp'), 5) ?
>>> If that is the case I'll make a patch for dblib.pp and will add an
>>> application parameter to mssqlconn.
>>
>> Yes, I confirm. The ApplicationName was shown in Profiler tool.
>
> Patch in http://bugs.freepascal.org/view.php?id=24635. New parameter is
> "ApplicationName".

Applied.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SQLdb: TMSSQLConnection: using Instance name in Host

Marcos Douglas B. Santos
In reply to this post by Ludo Brands
On Sat, Jun 22, 2013 at 10:39 AM, Ludo Brands <[hidden email]> wrote:

> On 06/22/2013 03:20 PM, Marcos Douglas wrote:
>> On Sat, Jun 22, 2013 at 4:35 AM, Ludo Brands <[hidden email]> wrote:
>>> Can you confirm it works with dbsetlname(FDBLogin, PChar('MyApp'), 5) ?
>>> If that is the case I'll make a patch for dblib.pp and will add an
>>> application parameter to mssqlconn.
>>
>> Yes, I confirm. The ApplicationName was shown in Profiler tool.
>
> Patch in http://bugs.freepascal.org/view.php?id=24635. New parameter is
> "ApplicationName".

Thank you.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal