hi try this
create stored procedure
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[usp_SearchRoomDetails]
@RoomNo varchar(50)
AS
BEGIN
SET NOCOUNT ON;
SELECT * from RoomDetailsTab where RoomNo=@RoomNo
END
and call this sp in page
protected void Search_Click(object sender, ImageClickEventArgs e)
{
string RoomNo = "";
RoomNo = txtRoomNo.Text;
SqlConnection cnn = new SqlConnection(ConfigurationManager.AppSettings["dbConnection"].ToString());
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_SearchRoomDetails";
SqlParameter pRoomNo = new SqlParameter("@RoomNo", SqlDbType.VarChar, 50);
pRoomNo.Value = RoomNo;
cmd.Parameters.Add(pRoomNo);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
txtRNo.Text = dt.Rows[0]["RoomNo"].ToString();
txtDetails.Text = dt.Rows[0]["Details"].ToString();
}
if (dt.Rows.Count == 0)
{
Response.Write("No result found");
}
cnn.Close();
}
try this
happy coding..