Click here to Skip to main content
15,914,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friend...

In my web application report page is there.

I need to take report from DB ,by passing value from front end.

How to pass value and get value from stord procedure.

Can u please help me
Posted

Use the below code:
C#
SqlConnection cn = new SqlConnection("your connection string");
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText="storedprocedure name";
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("value in sp","datatype of that value","size").value="your value to be passed".
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds,"tbl");

then you will get the table into the dataset "ds".
you can retrieve them as:
C#
ds.Tables[0].Rows[0]["cellname"].ToString();
 
Share this answer
 
v2
This article shows the way to do it.

A Beginner's Tutorial for Understanding ADO.NET[^]
 
Share this answer
 
You need to use SQL injection.

Some thing like
SQL
Sqlcommand com = new SqlCommand("Select * from <tablename> where name=@name",con);
com.parameters.addWithValue("@name",textboxname);
 
Share this answer
 
v2
Is google broken at your place?

Google[^]

Anyway, this is what MSDN says about it:

http://support.microsoft.com/kb/310070[^]
 
Share this answer
 
 
Share this answer
 
hi,

u can get value from SP using output parameter .
to do this refer following link
How to retrieve output parameter from Store procedure and get value in vb.net?[^]

Hope its help u
Best Luck
 
Share this answer
 

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