N
nbs.tag
Hi, ive created a webservice that im going to use to filter a table,
however when i try to pass the parameters in that will be used, it
crashes in the webbrowser with:
System.InvalidCastException: Failed to convert parameter value from a
SqlParameter to a Int32. ---> System.InvalidCastException: Object must
implement IConvertible.
ive tried rewriting this code a few different ways over and over again
to no avail, at the moment this is what my code looks like:
[WebMethod]
public string Search3(int Language, int SecurityLevel, double
PerDiem, bool WorkNS, bool WorkNB, bool WorkPE, bool WorkNL)
{
Database db = DatabaseFactory.CreateDatabase();
string proc = storedProcedure;
SqlParameter[] sqlParameters = new SqlParameter[]
{
new SqlParameter("@Language", Language),
new SqlParameter("@SecurityLevel", SecurityLevel),
new SqlParameter("@DiemAmount", PerDiem),
new SqlParameter("@WorkNS", WorkNS),
new SqlParameter("@WorkNB", WorkNB),
new SqlParameter("@WorkPE", WorkPE),
new SqlParameter("@WorkNL", WorkNL)
};
DbCommand cmd = db.GetStoredProcCommand(proc,
sqlParameters);
IDataReader ir = db.ExecuteReader(cmd);
return ir.ToString();
}
however ive also tried:
[WebMethod]
public XmlDocument Search(int Language, int SecurityLevel,
double PerDiem, bool WorkNS, bool WorkNB, bool WorkPE, bool WorkNL)
{
// DataSet ds;
Database db = DatabaseFactory.CreateDatabase();
SqlParameter[] sqlParameters = new SqlParameter[]
{
new SqlParameter("@Language", Language),
new SqlParameter("@SecurityLevel", SecurityLevel),
new SqlParameter("@DiemAmount", PerDiem),
new SqlParameter("@WorkNS", WorkNS),
new SqlParameter("@WorkNB", WorkNB),
new SqlParameter("@WorkPE", WorkPE),
new SqlParameter("@WorkNL", WorkNL)
};
IDataReader ir = db.ExecuteReader(storedProcedure,
sqlParameters);
XmlDocument doc = new XmlDocument();
doc.LoadXml(ir.ToString());
return doc;
}
any ideas? they both crash to the same error?
however when i try to pass the parameters in that will be used, it
crashes in the webbrowser with:
System.InvalidCastException: Failed to convert parameter value from a
SqlParameter to a Int32. ---> System.InvalidCastException: Object must
implement IConvertible.
ive tried rewriting this code a few different ways over and over again
to no avail, at the moment this is what my code looks like:
[WebMethod]
public string Search3(int Language, int SecurityLevel, double
PerDiem, bool WorkNS, bool WorkNB, bool WorkPE, bool WorkNL)
{
Database db = DatabaseFactory.CreateDatabase();
string proc = storedProcedure;
SqlParameter[] sqlParameters = new SqlParameter[]
{
new SqlParameter("@Language", Language),
new SqlParameter("@SecurityLevel", SecurityLevel),
new SqlParameter("@DiemAmount", PerDiem),
new SqlParameter("@WorkNS", WorkNS),
new SqlParameter("@WorkNB", WorkNB),
new SqlParameter("@WorkPE", WorkPE),
new SqlParameter("@WorkNL", WorkNL)
};
DbCommand cmd = db.GetStoredProcCommand(proc,
sqlParameters);
IDataReader ir = db.ExecuteReader(cmd);
return ir.ToString();
}
however ive also tried:
[WebMethod]
public XmlDocument Search(int Language, int SecurityLevel,
double PerDiem, bool WorkNS, bool WorkNB, bool WorkPE, bool WorkNL)
{
// DataSet ds;
Database db = DatabaseFactory.CreateDatabase();
SqlParameter[] sqlParameters = new SqlParameter[]
{
new SqlParameter("@Language", Language),
new SqlParameter("@SecurityLevel", SecurityLevel),
new SqlParameter("@DiemAmount", PerDiem),
new SqlParameter("@WorkNS", WorkNS),
new SqlParameter("@WorkNB", WorkNB),
new SqlParameter("@WorkPE", WorkPE),
new SqlParameter("@WorkNL", WorkNL)
};
IDataReader ir = db.ExecuteReader(storedProcedure,
sqlParameters);
XmlDocument doc = new XmlDocument();
doc.LoadXml(ir.ToString());
return doc;
}
any ideas? they both crash to the same error?