开发者

Parameter has no value

string queryString = "SELECT SUM(skupaj_kalorij)as Skupaj_Kalorij  "
                    + "FROM (obroki_save LEFT JOIN users ON obroki_save.ID_uporabnika=users.ID)"
                    + "WHERE users.ID= " + a.ToString() + " AND obroki_save.datum =?";


using (OleDbCommand cmd = new OleDbCommand(queryString,database))开发者_StackOverflow                                    
{
    cmd.Parameters.Add("@datum", OleDbType.Char).Value = DateTime.Now.ToShortDateString();    
}

Why doesn't the parameter datum get the date value? (the value of at least one complex parameter has not been determined )


From the docs for OleDbCommand.Parameters

The OLE DB .NET Provider does not support named parameters for passing parameters to an SQL Statement or a stored procedure called by an OleDbCommand when CommandType is set to Text. In this case, the question mark (?) placeholder must be used.

Try using the positional approach instead, basically.


If that's cut straight from your code then it might be giving an error because it needs a space in your queryString before the WHERE clause.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜