Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c# stored procedure to Data Table problem1

Status
Not open for further replies.

PureDevelopers

IS-IT--Management
Aug 25, 2006
18
US
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);
 
Are you getting any error? At which place?
Post the exact error message/code, so that we can help you...

Sharing the best from my side...

--Prashant--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top