TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
poornima sekar
NA
25
0
How to call and use stored procedure in codebehind page?
Nov 2 2016 3:32 AM
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
Reply
Answers (
8
)
Bind a drop downlist in edititemtemplate
Logical programs