0
 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?

ssarabando
  • 3,397
  • 2
  • 36
  • 42
john cenator
  • 33
  • 2
  • 7

1 Answers1

1

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);
Ivan Stoev
  • 195,425
  • 15
  • 312
  • 343