Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
8
Reply
How to call and use stored procedure in codebehind page?
poornima sekar
Nov 2 2016 3:32 AM
241
Reply
Hi,
I need to call stored procedure and use that values in codebehind page.
Below is my coding,
public Room1 GetRoomById(int Id)
{
string cs = ConfigurationManager.ConnectionStrings["LinqChatConnectionString"].ConnectionString;
DataSet dt = new DataSet();
try
{
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("GetRoomById", con);
cmd.Parameters.AddWithValue("@RoomID", Convert.ToInt32(lblRoomId.Text));
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
Room1 room = new Room1();
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (dt)
{
sda.Fill(dt);
room=dt; //Getting Error. Here I don't know how to assign the retrieved values to the object.
}
}
}
}
catch(Exception ex)
{ }
}
Please help me to overcome this issue.
Thanks,
Poornima
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
8
)
Next Recommended Forum
Bind a drop downlist in edititemtemplate
Logical programs