Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

Can I have, sample stored procedure code ,which will return a data Table

query will be "select * from TableName"

and how can I receive this value in C# code


Thanks,
praveen Machat
Posted

The same way you would if you were executing the query directly: with an SqlDataAdapter into a DataTable or DataSet, or with a SqlDataReader. Your choice.

Executing a stored procedure is exactly the same as if you had issued the code inside the procedure directly as a text query.

[edit]Typo: SqlDateReader indeed! - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
praveenmachat 11-Jul-14 12:40pm    
sorry,

my knowledge is limited ,

Can I have a sample code

or you mean to say use code like below

DataTable dt = new DataTable();

ADPTR = new SqlDataAdapter("exec procedureName", "connection string");

ADPTR.Fill(dt );


Thanks,
Praveen
 
Share this answer
 
Comments
praveenmachat 11-Jul-14 14:27pm    
For all this cases, if apostrophe is there in where condition.
I could not retrieve values properly.
kindly advise

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900