Reputation: 33
lala.Parameters.Add(new OleDbParameter("@Base", OleDbType.SmallInt).Value = textBox15.Text);
textBox15.Text = reader["@Base"].ToString();
The following error occurs in the first line of code
OleDBParameterCollection only accepts non null values OleDbparmeter type objects
Any suggestions?
Upvotes: 0
Views: 3600
Reputation: 205569
new OleDbParameter("@Base", OleDbType.SmallInt).Value = textBox15.Text
is an assignment expression of type string
. So lala.Parameters.Add(new OleDbParameter("@Base", OleDbType.SmallInt).Value = textBox15.Text);
actually is calling OleDbParameterCollection.Add Method (Object)
(https://msdn.microsoft.com/en-us/library/ms136047(v=vs.110).aspx). And obviously string
is not a OleDbParameter
object.
The correct way is to use local variable:
var parameter = new OleDbParameter("@Base", OleDbType.SmallInt);
parameter.Value = textBox15.Text;
lala.Parameters.Add(parameter);
Upvotes: 1