error ExecuteNomQuery

(1/2) > >>

andaluz:
Hola a todos, tengo un error en este código que no consigo solucionar, el error esta en Comando.ExecuteNonQuery() me dice:
      No coinciden los tipos de datos en la expresión de criterios.

Código
Private Sub btn_Comprar_Articulo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Comprar_Articulo.Click
       ' compruebo que ninguno de los datos de reparacion esta vacio
       ' compra por articulo
       If grb_Datos_Articulo.Enabled = False Then
           If cbb_B_Arc_Marca_Compras.Text = "" Or cbb_B_Arc_Articulo_Compras.Text = "" Or
               cbb_Nomb_Emp_Compra.Text = "" Or cbb_Apel_Emp_Compra.Text = "" Or
               txt_Numero_de_Artículos_Compra.Text = "" Or txt_Num_Serie_Compra.Text = "" Then
               MessageBox.Show("Alguno/s de los campos esta vacio, rellenelo/s", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
               Exit Sub
           End If
       Else
           If grb_Buscar_Art_por_Marca.Enabled = False Then
               If cbb_Nombre_Empres_Compras.Text = "" Or cbb_Modelo_Compra.Text = "" Or cbb_Articulo_Compra.Text = "" Or
               cbb_Nomb_Emp_Compra.Text = "" Or cbb_Apel_Emp_Compra.Text = "" Or
               txt_Numero_de_Artículos_Compra.Text = "" Or txt_Num_Serie_Compra.Text = "" Then
                   MessageBox.Show("Alguno/s de los campos esta vacio, rellenelo/s", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
                   Exit Sub
               End If
           End If
       End If
 
       ' consulta para asignar el Id_Articulo eligiendo la marca
       Dim id_artic As Integer
       Dim dtadapterArticulo1 As New OleDb.OleDbDataAdapter("SELECT Id_Articulos FROM Articulos WHERE Articulos.Descripcion='" & cbb_B_Arc_Articulo_Compras.Text & "' ORDER BY Articulos.Id_Articulos", conexion_access)
       Dim dtsArticulo As New DataSet
 
       dtadapterArticulo1.Fill(dtsArticulo, "Articulos")
       For Each Fila As DataRow In dtsArticulo.Tables("Articulos").Rows
           id_artic = Fila("Id_Articulos")
       Next
 
       ' consulta para asignar el Id_empleado eligiendo el empleado
       Dim id_emp As Integer
       Dim dtadapterEmpleado As OleDbDataAdapter = New OleDbDataAdapter("SELECT Empleados.Id_Empleado FROM Empleados WHERE Empleados.Nombre='" & cbb_Nomb_Emp_Compra.Text & "' AND Empleados.Apellidos='" & cbb_Apel_Emp_Compra.Text & "'", conexion_access)
       Dim dtsEmpleado As New DataSet
 
       dtadapterEmpleado.Fill(dtsEmpleado, "Empleados")
       For Each Fila As DataRow In dtsEmpleado.Tables("Empleados").Rows
           id_emp = Fila("Id_Empleado")
       Next
 
       MsgBox("Ejecutando consulta")
       Dim CadenaSql As String = "INSERT INTO Stock (Num_Serie, Vendido, Fecha, Id_Articulo, Id_Empleado) VALUES ('" & txt_Num_Serie_Compra.Text & "', False, '" & cbb_Fecha_Compra.Text & "'," & id_artic & "," & id_emp & ")"
       Dim Comando As New OleDbCommand(CadenaSql, conexion_access)
       Comando.Connection.Open()
       Comando.ExecuteNonQuery()
 
       ' recimensionamos el tamaño de la matriz
       ReDim Preserve S_Stock(S_Stock.Length)
 
       ' para refrescar la tabla me tengo que crear 2 variables
       Dim ta_stock As New ArcoclimaDataSetTableAdapters.StockTableAdapter
       Dim tabla_stock As New ArcoclimaDataSet.StockDataTable
 
       ' refrescamos los valores de la tabla
       tabla_stock = ta_stock.GetData
       StockDataGridView.DataSource = tabla_stock
 
       Me.Validate()
       Me.StockBindingSource.EndEdit()
       Me.TableAdapterManager.UpdateAll(Me.ArcoclimaDataSet)
 
       ' limpio el contenido de los TextBox que he insertado en la tabla Stock
       Limpiar_TextBox(cbb_Nombre_Empres_Compras.Text, cbb_Modelo_Compra.Text, cbb_Articulo_Compra.Text,
                       cbb_B_Arc_Marca_Compras.Text, cbb_B_Arc_Articulo_Compras.Text, cbb_Nomb_Emp_Compra.Text,
                       cbb_Apel_Emp_Compra.Text, txt_Numero_de_Artículos_Compra.Text, txt_Num_Serie_Compra.Text)
 
       Comando.Connection.Close()
 
   End Sub
 

Espero que me puedan ayudar

Saludos

HdM:
Buenas.

Código
Dim CadenaSql As String = "INSERT INTO Stock (Num_Serie, Vendido, Fecha, Id_Articulo, Id_Empleado) VALUES ('" & txt_Num_Serie_Compra.Text & "', False, '" & cbb_Fecha_Compra.Text & "'," & id_artic & "," & id_emp & ")"

¿De qué tipo es el campo Fecha en la tabla Stock?

Saludos.

andaluz:
el campo feche es de tipo date

HdM:
Buenas.

Por eso te lo decia. Intentas grabar como si fuese texto.

Saludos.

andaluz:
que le tendria que hacer un Cdate(cbb_Fecha_Compra.Text)???

Navegación

[0] Índice de Mensajes

[#] Página Siguiente