i am trying to populate a gridview with a stored procedure and some parameters. for some oddball reason, i get this error:
"when converting a string to datetime parse the string to take the date before putting each variable into the datetime object"
the odd thing is, i'm not trying to pass a datetime parameter, though the stored procedure does use the fn CURDATE() to filter some of the objects, but that should be taken care of in the sql right?
the error comes at the dataAdapter.Fill line.
here's the code.
ALTER PROCEDURE SearchAllPlayers
(
@personName,
@IDs
)
SELECT DISTINCT
person.personID, sports.sportsID, person.personName, sports.sport,
FROM sports INNER JOIN
person INNER JOIN
personSport ON personSport.personID = person.personID
INNER JOIN
personSport ON personSport.sportID = sports.sportsID
WHERE (person.personName LIKE '%' + @personName + '%')
AND
(person.regDate >= { fn CURDATE() }
AND
(sports.sportID IN
(SELECT ID FROM dbo.fnSplitter(@IDs) AS fnSplitter_1) OR @IDs = 0)
protected void Button1_Click(object sender, EventArgs e)
{
searchGrid();
}
protected void searchGrid()
{
SqlConnection conn = new SqlConnection(connSTR);
com = new SqlCommand();
conn.Open();
com.Connection = conn;
com.CommandText = "SearchAllPlayers";
com.CommandType = CommandType.StoredProcedure;
string StringWithDelimiter = string.Empty;
for (int i = 0; i < DropDownCheckBoxes1.Items.Count; i++)
{
if (DropDownCheckBoxes1.Items[i].Selected)
StringWithDelimiter += DropDownCheckBoxes1.Items[i].Value + ";";
}
com.Parameters.Add("@personName", SqlDbType.VarChar).Value = personName.Text;
com.Parameters.Add("@IDs", SqlDbType.VarChar).Value = StringWithDelimiter;
sqlDa = new SqlDataAdapter(com);
dS = new DataSet();
sqlDa.Fill(dS);
conn.Close();
GridView1.DataSource = dS;
GridView1.DataBind();
}
i cannot understand why i would have this issue. please help