protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["dbConnection"].ToString()); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "ups_JoinRegistration3"; //cmd.Parameters.Add("@UserID", SqlDbType.Int); cmd.Connection = con; con.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); dlProfile.DataSource = dt; dlProfile.DataBind(); cmd.Dispose(); con.Close(); } protected void dlProfile_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "Details") { Label lb = new Label(); lb = (Label)e.Item.FindControl("Label2"); string ID = lb.Text; ////string UserId = ""; //int id = Convert.ToInt32(Request.QueryString["en"].ToString()); //string UserId = Convert.ToString(e.CommandArgument); Response.Redirect("ViewDetails.aspx?@ID=" + ID);
System.Data.SqlClient.SqlException: Procedure or Function 'ups_JoinRegistration3' expects parameter '@ID', which was not supplied.
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["dbConnection"].ToString()); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = Convert.ToInt32(Request.QueryString["@ID"].ToString()); //string id = Request.QueryString["en"].ToString(); SqlCommand cmd = new SqlCommand("ups_JoinRegistration3", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = id; cmd.Connection = con; con.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); dlProfile.DataSource = dt; dlProfile.DataBind(); cmd.Dispose(); con.Close(); }
ALTER PROCEDURE [dbo].[ups_JoinRegistration3] (@ID int) AS BEGIN select * from Registration where ID=@ID END
ID int UserId int FirstName nvarchar(50) MiddleName nvarchar(50) LastName nvarchar(50) DateOfBirth nvarchar(50) Gender nvarchar(50) Email nvarchar(50) Occupation nvarchar(50) State nvarchar(50) City nvarchar(50) Nationality nvarchar(50)
create PROCEDURE [dbo].[ups_JoinRegistration3] AS BEGIN select * from Registration
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)