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!

Problem with SP

Status
Not open for further replies.

PatrickIRL

Programmer
Jun 25, 2003
383
Hi, I have a stored procedure (sql server) with 3 parameters that runs fine in query analyzer but returns nothing when I run it through my web page.

Code:
ALTER PROCEDURE [dbo].[PROCEDURENAME]
	@stateschoolID varchar(100),
	@gender int,
	@grades varchar(100)
AS
	SELECT 
		*
	FROM
		<TABLE>
	WHERE
		stateSchoolID_c = @stateschoolID AND
		gender_n = @gender AND
		gradeID_c IN (@grades)

I think the problem may be the way I'm using the IN statement for the grades. It can be a list so I could pass in a value such as '01','04'

This is how I call it...

Code:
using (IDbCommand cmd = cn.CreateCommand())
{
	cmd.CommandText = "PROCEDURENAME";
      cmd.CommandType = CommandType.StoredProcedure;
      //
      IDbDataParameter pmStateSchoolID = cmd.CreateParameter();
      pmStateSchoolID.ParameterName = "@stateSchoolID";
      pmStateSchoolID.Value = _stateSchoolID;
      cmd.Parameters.Add(pmStateSchoolID);
      //
      IDbDataParameter pmGender = cmd.CreateParameter();
      pmGender.ParameterName = "@gender";
      pmGender.Value = Convert.ToInt16(gender);
      cmd.Parameters.Add(pmGender);
      //
      IDbDataParameter pmGrades = cmd.CreateParameter();
      pmGrades.ParameterName = "@grades";
      pmGrades.Value = grade;
      cmd.Parameters.Add(pmGrades);
      //
      using (IDataReader dr = cmd.ExecuteReader())
      {
      	while (dr.Read())
            {
		}
	}
}

Any ideas ????

Thanks in advance, Patrick
 
Never mind, I looked at faq183-5207 and solved it using the function created by donutman.

Patrick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top