PureDevelopers
IS-IT--Management
Trying to run a stored procedure and place it in a data table. Can't figure out the problem. Any Help?
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand myCommand = new SqlCommand("pr_GetPlayers", con);
myCommand.Parameters.Add("@iPlayerID", System.Data.SqlDbType.Int);
myCommand.Parameters.Add("@cLastName", System.Data.SqlDbType.VarChar, 100);
myCommand.Parameters.Add("@cFirstName", System.Data.SqlDbType.VarChar, 100);
myCommand.Parameters.Add("@cGender", System.Data.SqlDbType.Char, 1);
myCommand.Parameters.Add("@iAgeFrom", System.Data.SqlDbType.Int);
myCommand.Parameters.Add("@iAgeTo", System.Data.SqlDbType.Int);
myCommand.Parameters.Add("@cLevel", System.Data.SqlDbType.VarChar, 200);
myCommand.Parameters["@iPlayerID"].Value = Convert.ToInt32(Session["PID"]);
myCommand.Parameters["@cLastName"].Value = this.txtLastName.Text;
myCommand.Parameters["@cFirstName"].Value = this.txtFirstName.Text;
myCommand.Parameters["@cGender"].Value = this.ddlGender.SelectedValue.ToString();
myCommand.Parameters["@iAgeFrom"].Value = AgeFrom;
myCommand.Parameters["@iAgeTo"].Value = AgeTo;
myCommand.Parameters["@cLevel"].Value = level;
myCommand.CommandType = CommandType.StoredProcedure;
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(myCommand);
adapter.Fill(dt);
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand myCommand = new SqlCommand("pr_GetPlayers", con);
myCommand.Parameters.Add("@iPlayerID", System.Data.SqlDbType.Int);
myCommand.Parameters.Add("@cLastName", System.Data.SqlDbType.VarChar, 100);
myCommand.Parameters.Add("@cFirstName", System.Data.SqlDbType.VarChar, 100);
myCommand.Parameters.Add("@cGender", System.Data.SqlDbType.Char, 1);
myCommand.Parameters.Add("@iAgeFrom", System.Data.SqlDbType.Int);
myCommand.Parameters.Add("@iAgeTo", System.Data.SqlDbType.Int);
myCommand.Parameters.Add("@cLevel", System.Data.SqlDbType.VarChar, 200);
myCommand.Parameters["@iPlayerID"].Value = Convert.ToInt32(Session["PID"]);
myCommand.Parameters["@cLastName"].Value = this.txtLastName.Text;
myCommand.Parameters["@cFirstName"].Value = this.txtFirstName.Text;
myCommand.Parameters["@cGender"].Value = this.ddlGender.SelectedValue.ToString();
myCommand.Parameters["@iAgeFrom"].Value = AgeFrom;
myCommand.Parameters["@iAgeTo"].Value = AgeTo;
myCommand.Parameters["@cLevel"].Value = level;
myCommand.CommandType = CommandType.StoredProcedure;
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(myCommand);
adapter.Fill(dt);