levyuk
Well-known member
Trying to INSERT into an Access database but I keep getting this message.
An OleDbParameter with ParameterName '@Details' is not contained by this OleDbParameterCollection.
Here is my code
Any ideas why it doesn't work, because from what I can tell it should do
Thanks for any help
An OleDbParameter with ParameterName '@Details' is not contained by this OleDbParameterCollection.
Here is my code
VB.NET:
[size=2][color=#0000ff]Dim[/color][/size][size=2] sql [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]String
[/color][/size][size=2]sql = "INSERT INTO events (Details) VALUES (@Details)"
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] SQLreturn [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]Integer
[/color][/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbCommand1.CommandText = sql
[/size][size=2][color=#0000ff]Try
[/color][/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbConnection1.Open()
[/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbCommand1.Parameters("@Details").Value = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].TextBoxDetails.Text
SQLreturn = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbCommand1.ExecuteNonQuery
[/size][size=2][color=#0000ff]Catch[/color][/size][size=2] ex [/size][size=2][color=#0000ff]As[/color][/size][size=2] Exception
MessageBox.Show(ex.Message)
[/size][size=2][color=#0000ff]Finally
[/color][/size][size=2][color=#0000ff]Me[/color][/size][size=2].OleDbConnection1.Close()
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Try
[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2] SQLreturn <> 1 [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]MessageBox.Show("Insert failed")
[/size][size=2][color=#0000ff]Else
[/color][/size][size=2]MessageBox.Show("INSERT completed")
TextBoxDetails.Text = ""
TextBoxDate.Text = ""
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
[/color][/size]
Any ideas why it doesn't work, because from what I can tell it should do
Thanks for any help