[Lazarus] Accessing MS SQLServer database from Lazarus/FPC?

Dipl. Phys. Jörg Schläger js at jsdevelop.de
Sun Jan 23 20:10:49 CET 2011



Zitat von Bo Berglund <bo.berglund at gmail.com>:

> On Sun, 23 Jan 2011 18:23:25 +0100, "Dipl. Phys. Jörg Schläger"
> <js at jsdevelop.de> wrote:
>
>>
>> Zitat von Bo Berglund <bo.berglund at gmail.com>:
>>
>>> On Sun, 23 Jan 2011 13:53:45 +0100, "Dipl. Phys. Jörg Schläger"
>>> <js at jsdevelop.de> wrote:
>>>
>>>>
>>>> and next you might think of using query.SQL.Text := 'EXEC
>>>> SelectDongleData @@SerialNo=2485';
>>>
>>> Tried adding an extra @ to parameter.
>>> Results are as follows:
>>>
>>> EXEC SelectDongleData @@SerialNo=2485
>>>
>>> 'Cannot open a non-select statement'
>>>
>>> EXECUTE SelectDongleData @@SerialNo=2485
>>>
>>> 'Could not execute statement. ODBC error details: LastReturnCode:
>>> SQL_ERROR; Record 1: SqlState: 42000; NativeError: 8145; Message:
>>> [Microsoft][ODBC SQL Server Driver][SQL Server]@@SerialNo is not a
>>> parameter for procedure SelectDongleData.;'
>>
>> of course you have to change your sql statement to define @@SerialNo
>>
>> procedure SelectDongleData @@SerialNo int AS
>
> Why?
> It is already defined as follows:
>
> CREATE PROC dbo.SelectDongleData
> @SerialNo int = 0
> AS
>
> I don't see the reason to add another @ in the declaration. Can you
> explain this a bit?

I agree there is no reason, but it is from MS with historie 
local variable: declare @SerialNr int
in versions before MSsql  2008 @@ referr a GLOBAL variable that is the different
depending on server and client I had some problems with local variable declaration on some client config/version.

-- 
Dipl. Phys. Jörg Schläger

>
> --
> Bo Berglund
> Developer in Sweden
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>


----------------------------------------------------------------
Dip. Phys. Jörg Schläger
Auftragsentwicklung Meßtechnik
www.jsdevelop.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110123/8e486339/attachment-0003.html>


More information about the Lazarus mailing list