error: oledbexception nust declare the variable '@Eff_Date'

Here is the code in my Load event after declaring cn, da and cm

cn.ConnectionString = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=matrix;Integrated Security=SSPI;"

cm = New OleDbCommand("select * from lk_Feat", cn)
cm.Connection = cn
da.SelectCommand = cm
cm = New OleDbCommand("UPDATE Lk_Feat SET
Eff_Date=@Eff_Date, Exp_Date = @Exp_Date......etc..., cn)

cm.Parameters.Add("@Eff_Date",System.Data.OleDb.OleDbType.Date,8, ''Eff_Date'')

cm.Parameters.Add("@Exp_Date",System.Data.OleDb.OleDbType.Date,8, ''Exp_Date'')

........and all other fields of my table, then:

da.UpdateCommand = cm

da.Fill(ds)

In a button in my form I do this in its click event:

I modify my dataset ds

then I call: da.update(ds)

But I get the error: oledbexception nust declare the variable '@Eff_Date'

I actually get that error even if I don t modify the dataset. even if i leave it non modified

Any ideas pls

Thanks a lot.




Answer this question

error: oledbexception nust declare the variable '@Eff_Date'

  • David OShaughnessy

    I see what u mean, I ll try that. I don t think that s what they say in MSDN of visual studio 1.0. thanks a lot.

  • SilverKnight

    how about if we want to use the same parameter twice in the Update query. putting just question marks in the query won't tell the framework that we are using @Eff_date for example twice in the query (for example in the set portion and in the Where portion of SQL query)

    Thanks.



  • Xiao Feng

    Here is a reference on the different parameter styles with the various .NET data providers: http://msdn2.microsoft.com/en-us/library/yy6y35y8(d=ide).aspx

    Thanks,
    Sarah



  • Mal555


    I didn't see any examples using named parameters in a SQL statement, other than those for the native .NET SQL Server provider. If you can find the page or topic you might want to post it here.



  • coreyw2008


    Since the ADO.NET/OLEDB .NET Framework library combination does not support named parameters I don't believe this would be possible. You must have the same number of parameters as positional place holders.

  • ampijanka

    I think my code works fine now. thanks a lot. did u see in the VS2003 doc , they didn t mention questionnmarks for oledbcommand command text properties. theyt mentioned @param

    thanks again for your help.



  • mouvement_patisserie


    With OLEDB you should be using a question mark place holder instead of a named parameter in your SQL statement.

  • error: oledbexception nust declare the variable '@Eff_Date'