Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure passing param-Execution in Delphi XE2 using DbExpress

Status
Not open for further replies.

cristianvasuica

Programmer
Dec 19, 2011
3
RO
Hi there..Could anyone please help me out because I am stuck with a MS SQL stored procedure execution.I am new to programming and I have to build an application about employee`s evidence.I use Delphi XE2 and MS SQL.So here it is: I have a stored procedure to select fields name, surname, email addres from table employees where @name='something'.. So i built a form and I dragged a sql connection, sql stored procedure, dataset provider , a client dataset and a datasource, a editbox, a grid, and a button. When i press click on the button I want to see the results of executing the stored procedure into my grid. I resolved with the grid`s columns(name, surname, emailadressa),but i dont know how to pass parametres; on SQLStoredProc component I have asigned on parametre @name=DBEdit1.Text and on the click event of the apply button SQLStoredProc.ExecProc; i have no compilation erros but when i try to enter values in the editbox i can not..and i dont know why..??..p.s. sorry for my bad english
 
thank you whosrdaddy .. but the thing is that I am not using ADO Components..ADO components are in the DbGo section, I am using DBExpress..what you have suggested me with the params property I have done it..but when I was compiling it was ok, but in the DBEdit box I wasn`t able to type anything..Now I have replaced DBEdit with TEdit and I can type into the EditBox but my stored procedure excution returns an error..if anyone could please have a simple example on how to use a stored proc with a parametre I would be gratefull.
 
Ow didn't see that.
Any reason why you WANT to use DBExpress?
ADO is far more robust and versatile...

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I discovered what it was...i tried to pass the params at running time and it works..for others who will run into this first you need to write the prepare statement of the procedure: SQLStoredProc1.Prepare:=True;
SQLStoredProc1.Params[1].AsString := Edit1.Text;
SQLStoredProc1.Params[2].AsString := Edit2.Text;
SQLStoredProc1.ExecProc;
Edit3.Text := SQLStoredProc1.ParamByNam('@RETURN_VALUE').AsString;
In this exemple I have a procedure with 2 parameters and because I use MS SQL as a DB Engine it automatically returns a result parameter.
to: whosrdaddy I am the begging of learning programing and I didn`t used ADO because I haven`t yet read too much about it..I have studied more the dbExpress components..which is more used? ADO or DBExpress?
 
ADO is more widespread. Every major programming language supports it and you don't depend on the proprietary dbexpress dll's. ADO is by standard included in the 3 last generation OS'es.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top