c# - Data type mismatch when inserting into table -
I'm having some issues with putting data called Microsoft Access Table in the order
I The method that is listed has been created in my data access layer and called through a button click event in my presentation layer. The error I am getting is:
The data type mismatch in the criteria expression
The data access layer method:
public static void processOrder (integer EmployeeID, integer TableID DATETIME, ORDERDATE DATETIME, orderBegin, bool orderStatus) {try {If (KaiConnection.State == ConnectionState.Closed) KaiConnection.Open (); OleDbCommand cmd = inserting new OleDbCommand (+ "???? values (,,,,)", KaiConnection "[Order] (EmployeeID, [TableID], OrderDate OrderBegin, OrderStatus"); //cmd.CommandText = sSQLCommand; Cmd.Parameters.AddWithValue ("?", Employee ID); Cmd.Parameters.AddWithValue ("?", Table ID); Cmd.Parameters.AddWithValue ("?", Order Date); Cmd.Parameters.AddWithValue ("?", Commandben); Cmd.Parameters.AddWithValue ("?", Order status); // execute SQL command cmd.ExecuteNonQuery (); KaiConnection.Close (); } Hold (Exception pre) {Message Box. Showing (ex.ToString ()); }}
Presentation Layer button click event:
private void BtnProcessOrder_Click (object sender, EventArgs e) {Order order = new Order (); AnOrder.EmployeeId = empId; AnOrder.TableId = int.Parse (txtTableID.Text); AnOrder.OrderDate = DateTime.Today; AnOrder.OrderBegin = DateTime.Now; AnOrder.OrderStatus = True; AnOrder.processOrder (); }
This is a
OleDbParameter
class of your code:public static void processOrder (integer EmployeeID, integer TableID DATETIME, ORDERDATE DATETIME, orderBegin, bool orderStatus) {try {if (KaiConnection.State == ConnectionState.Closed) KaiConnection.Open (); OleDbCommand cmd = new OleDbCommand (+ "values (@EmployeeID, @TableID, putting @OrderDate, @OrderBegin, @OrderStatus)", KaiConnection "[command] (EmployeeID, [TableID], OrderDate OrderBegin, OrderStatus)"); OlendiPeramator [] Parameters = new OlendipiPromator [5]; Criterion [0] = New OLDBPMATOR ("@EmplierID", Oleedib Type Integer); Parameters [1] = New OLDbPameter ("@ TableID", Oleedib Type etaser); Parameters [2] = New Oleadbapamator ("@ Order Date", Oleadby Type. Date); Parameters [3] = New OLDbPamator ("@orderbigen", Oleedib Type Dot); Parameters [4] = New OLDbPamator ("@orderStatus", Oleadby TypeBolin); Parameter [0]. Value = employee ID; Parameter [1]. Value = table id; Parameter [2]. Value = order date; Parameters [3]. Price = order; Parameter [4]. Value = orderstats; (Int i = 0; i & lt; 5; for i ++) (CMD. Paramitr.ad (criteria [i]);} Cmd.ExecuteNonQuery (); cmd.Parameters.Clear (); KaiConnection.Close ( );} catch (exception ex) {message box. show ((ex.ToString ()));}}
Comments
Post a Comment