Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rtutus
Aged Yak Warrior
522 Posts |
Posted - 2006-06-15 : 13:36:41
|
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 dsthen 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 modifiedAny ideas plsThanks a lot. |
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2006-06-15 : 14:19:29
|
I'm not sure if you can do a parameters.add for an "adhoc" type query like that. The parameters.add is generally for Stored Procs that have declared parameters at the top. You may want to try declaring that parameter in your OleDbCommand and see if that works, but I suspect that it will not.cm = New OleDbCommand("DECLARE @EFF_Date DATETIMEDECLARE @Exp_Date DATETIMEUPDATE Lk_Feat SET Eff_Date=@Eff_Date, Exp_Date = @Exp_Date......etc...", cn) <Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights. |
 |
|
|
|
|
|
|