Sheikh parvaz

Sheikh parvaz

  • NA
  • 199
  • 108.7k

Get data from database

Nov 21 2012 3:55 AM
Help is needed. With this I want to get the data from table and print on labels using stored procedure. itz not woorking.

 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TicketConnectionString"].ConnectionString);
       
        SqlCommand cmd = new SqlCommand();
        protected void Page_Load(object sender, EventArgs e)
        {
           
            con.Open();
            cmd = new SqlCommand("GetTicketData", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "GetTicketData";
            lblType.Text = cmd.Parameters.AddWithValue("@Type", SqlDbType.NChar).ToString(); 
            lblDepartment.Text = cmd.Parameters.AddWithValue("@Department", SqlDbType.NVarChar).ToString();
            lblCategory.Text = cmd.Parameters.AddWithValue("@Category", SqlDbType.NChar).ToString();
            lblSubject.Text = cmd.Parameters.AddWithValue("@Title", SqlDbType.NVarChar).ToString();
            lblMessage.Text = cmd.Parameters.AddWithValue("@Detail", SqlDbType.NVarChar).ToString();
            lblCreatedBy.Text = cmd.Parameters.AddWithValue("@CreatedBy", SqlDbType.NVarChar).ToString();
            lblCDate.Text = cmd.Parameters.AddWithValue("@CreateDate", SqlDbType.DateTime).ToString();
            lblCurrentStatus.Text = cmd.Parameters.AddWithValue("@CurrentStatus", SqlDbType.NChar).ToString();
            lblCurrentSDate.Text = cmd.Parameters.AddWithValue("@CurrentStatusDate", SqlDbType.DateTime).ToString();
            lblCStatusSetBy.Text = cmd.Parameters.AddWithValue("@CurrentStatusSetBy", SqlDbType.NVarChar).ToString();
            lblLastUDate.Text = cmd.Parameters.AddWithValue("@LastUpdatedDate", SqlDbType.DateTime).ToString();
            lblLastUBy.Text = cmd.Parameters.AddWithValue("@LastUpdatedBy", SqlDbType.NVarChar).ToString();
            lblRoomNo.Text = cmd.Parameters.AddWithValue("@RoomNo", SqlDbType.NVarChar).ToString();
            lblAvailability.Text = cmd.Parameters.AddWithValue("@Availabilty", SqlDbType.NVarChar).ToString();
            cmd.ExecuteNonQuery();
        }
    }
}







procedure is as:=




ALTER PROCEDURE dbo.GetTicketData
@Type nchar(10),
@Department nvarchar(50),
@Category nchar(10),
@Title nvarchar(50),
@Detail nvarchar(MAX),
@CreatedBy nvarchar(256),
@CreateDate datetime,

@CurrentStatus nchar(10),
@CurrentStatusDate datetime,
@CurrentStatusSetBy nvarchar(50),
@LastUpdatedDate datetime,
@LastUpdatedBy nvarchar(50),
@RoomNo nvarchar(10),
@Availabilty nvarchar(50)
AS


/* SET NOCOUNT ON */
Begin
Select  Type, Department, Category, Title, Detail, CreatedBy, CreateDate, CurrentStatus, CurrentStatusDate, CurrentStatusSetBy, LastUpdatedDate, LastUpdatedBy, RoomNo, Availabilty From dbo.Ticket  
End






Answers (3)