• Lunes 29 de Abril de 2024, 11:57

Autor Tema:  Insertar Registro En Tabla Acces  (Leído 1246 veces)

STTR

  • Nuevo Miembro
  • *
  • Mensajes: 5
    • Ver Perfil
Insertar Registro En Tabla Acces
« en: Domingo 3 de Abril de 2005, 21:04 »
0
hola machines!! a ver si me podeis ayudar...

Estoy intentando insertar un nuevo registro en una tabla Acces.
Las conexiones a la bd las tengo exas por controles.
He probado de hacerlo con estos dos codigos y con variantes de los mismos pero siempre me da el mismo error:

1-----------------------------------------------------------------

CODIGO1:   

        Dim sqlInsert As String = "INSERT INTO Detalles_de_pedidos (Cantidad,Descuento,IdPedido,IdProducto,PrecioUnidad) VALUES (" & txtQuantitat.Text & "," & txtDescompte.Text & "," & cbComanda.Text & "," & cbProducte.Text & "," & txtPreu.Text & ")"
        daLineas.InsertCommand = New System.Data.OleDb.OleDbCommand(sqlInsert)
        daLineas.InsertCommand.Connection = cnnEMPRES
        cnnEMPRES.Open()
error-> daLineas.InsertCommand.ExecuteNonQuery()

ERROR:
       Excepción no controlada del tipo 'System.Data.OleDb.OleDbException' en system.data.dll


2-------------------------------------------------------------------

CODIGO2:

        Dim newLine As dsEMPRES.Detalles_de_pedidosRow
        newLine = DsEMPRES.Detalles_de_pedidos.NewRow
        newLine("IdPedido") = cbComanda.Text
        newLine("IdProducto") = cbProducte.Text
        newLine("Cantidad") = txtQuantitat.Text
        newLine("Descuento") = txtDescompte.Text
        newLine("PrecioUnidad") = txtPreu.Text

        DsEMPRES.Detalles_de_pedidos.AddDetalles_de_pedidosRow(newLine)
       
        daLineas.InsertCommand.Parameters("Cantidad").Value = txtQuantitat.Text
        daLineas.InsertCommand.Parameters("Descuento").Value = txtDescompte.Text
        daLineas.InsertCommand.Parameters("IdPedido").Value = cbComanda.Text
        daLineas.InsertCommand.Parameters("IdProducto").Value = cbProducte.Text
        daLineas.InsertCommand.Parameters("PrecioUnidad").Value = txtPreu.Text
       
error-> daLineas.Update(DsEMPRES.Detalles_de_pedidos)

ERROR:
   Excepción no controlada del tipo 'System.Data.OleDb.OleDbException' en system.data.dll

-----------------------------------------------------------------------------

S.O.S!!!  Algo hago mal verdad??? (Muchas Gracias por estar ahí)