dbExpress , MSSQL stored procedure params error

dbExpress , MSSQL stored procedure params error

Post by bogdan.pri » Thu, 08 Feb 2007 19:47:29


Hello,

First of all You must know that I'm kind of new to Delphi.
Background:
I need to write an app that reads and write data from/in MSSQL, and do
this with stored procedures.

My problem: I have made a form on witch I put:
SQLConnection1: TSQLConnection;
//Societate= Copany name
//StorePorc: GEN_ZoomSocietati ; no parameter required, return
data in dsSoc
dsSocietate: TDataSource;
sdsSocietate: TSQLDataSet;
cblSocietate: TDBComboBox;

//Locatie = Location
//StorePorc: GEN_ZoomDimensiuni ; no parameter required, return
data in dsLoc
dsLocatie: TDataSource;
sdsLocatie: TSQLDataSet;
cblLocatie: TDBComboBox;

// Gest =
//StorePorc: THG_GetGestiune ; parameter: idlocatie
// return a list of things that are linked by Location by the
idlocation field
dsGest: TDataSource;
sdsGest: TSQLDataSet;
cblGest: TDBComboBox;


I can execute the StoredProc that are without any params, and get the
date, and populate the combos like this:
dsSocietate.DataSet.First;
while not dsSocietate.DataSet.Eof do
begin
ss:= ToString(dsSocietate.DataSet.FieldValues['societate']);
cblSocietate.Items.Add(ss);
dsSocietate.DataSet.Next;
end;

dsLocatie.DataSet.First;
while not dsLocatie.DataSet.Eof do
begin
ss:= ToString(dsLocatie.DataSet.FieldValues['denumire']);
cblLocatie.Items.Add(ss);
dsLocatie.DataSet.Next;
end;

Here is my THG_GetGestiune StoreProc
CREATE PROCEDURE THG_GetGestiune
@idlocatie INT = NULL
AS
SET NOCOUNT ON
SELECT g.codgestiune, g.denumire, g.descarcare, g.codpersoana,
g.codgestionar
FROM thg_locatii_gestiuni lg
INNER JOIN gestiuni g ON lg.codgestiune = g.codgestiune
WHERE lg.idlocatie = @idlocatie
SET NOCOUNT OFF


THE QUESTION:
How can I pass a parameter to this stored procedure?
I have tried with:
sdsGest.CommandType := ctStoredProc;
sdsGest.CommandText := 'THG_GetGestiune';
sdsGest.ParamByName('@idlocatie').Value := 9;
sdsGest.ExecSQL;
and aplication crash.

Please help,
Tanks in advance
 
 
 

1. problem with stored procedures moving DB from MSSQL 2000 to MSSQL 2005

2. problem with stored procedures moving DB from MSSQL 2000 to MSSQL 2005

I have detached and attached several databases from MSSQL 2000 to
MSSQL 2005. Everything works fine but the stored procedures that I can
tell (they are there - I can see them). Any webpage that references a
stored procedures is returning the following error...

Microsoft OLE DB Provider for SQL Server error '80040e14'

Could not find stored procedure 'sp_UserAccess_Login'.

/dmsystem/admin/admin.asp, line 35

I have exhaustedly looked at the security in 2005 and I understand how
2005 uses schema security to control access to stored procedures. Is
there somethign I need to change in my code or is there something I
can do in my SQL server that will allow my webpages to access the
stored procedures?

Any help is greatly appreciated.

Bobby Thompson
SmartStream Inc.

3. Error when passing negative number as parameter to MSSQL stored procedure

4. error of the system stored procedure MSSQL Server

5. Error handling in stored procedure, MSSQL

6. Error when passing negative number as parameter to MSSQL stored procedure

7. Calling a stored procedure from a stored procedure and ignoring output from inner procedure call

8. Error connecting D6 to MSSQL Express via dbexpress

9. dbexpress +MSSQL errors

10. dbExpress, MSSQL, Using parameters and WITH(NOLOCK) with TSQLQuery.open() gives error

11. MSSQL Server Error with dbExpress

12. Parameter error in MSSQL - dbExpress

13. DBExpress MSSQL Driver Error !.....

14. dbexpress and mssql error

15. Unable to recognize stored procedure param