Visual Basic - Problemas para guardar registro en base de datos access desde visual basic

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil
Val: 1
Ha aumentado su posición en 94 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

Problemas para guardar registro en base de datos access desde visual basic

Publicado por Juan Carlos Rivas (1 intervención) el 05/07/2019 10:16:11
Buenoas dias estimados,

Tengo el siguiente problema, mediante codigo tengo una conexion a una base de datos en access y cuando creo un nuevo registros desde visual Basic (Visual Studio 2019) me dice que el registro se guardo pero cuando salgo del formulario invocando el envento FormClosing me da un error.

Estoy usando tambien parte del codigo publicado aqui en la web para generar un codigo QR con la informacion. Forma parte de AjpdSoft.

En la salida me dice que el programa termino codigo 0 (0x0) y me dice que se produjo una Excepción:
Excepción producida: 'System.Data.OleDb.OleDbException' en System.Data.dll
El subproceso 0xf038 terminó con código 0 (0x0).
El subproceso 0x11044 terminó con código 0 (0x0).
El programa '[68032] CodeQRme2.exe' terminó con código 0 (0x0).

Les dejo un par de imagenes y codigo a ver si me dan una mano:


Captura1
Captura2
Captura3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Private Sub formLesenGenerierenCodeQR_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    If MyState = "Edit" Or MyState = "Add" Then
        MessageBox.Show("You must finish the current edit before stopping the application.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
        e.Cancel = True
    Else
        Try
            'save the updated Projekt table
            Dim ProjektAdapterCommands As New OleDbCommandBuilder(ProjektAdapter)
            ProjektAdapter.Update(ProjektTable)
        Catch ex As Exception
            MessageBox.Show("Error saving database to file:" + ControlChars.CrLf + ex.Message, "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        'close the connection
        ProjektConnection.Close()
        'dispose of the objects
        ProjektConnection.Dispose()
        ProjektCommand.Dispose()
        ProjektAdapter.Dispose()
        ProjektTable.Dispose()
    End If
End Sub

1
2
3
Private Sub btnDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDone.Click
    Me.Close()
End Sub

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Private Sub formLeerGenerarCodigosQR_Load(sender As System.Object,
        e As System.EventArgs) Handles MyBase.Load
    lsNivelCorreccion.SelectedIndex = 1
    txtEscalaPixel.Text = 4
    'connect to Phone database
    ProjektConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source = c:\VBDB\Working\Projektme2.accdb;Persist Security Info = False; ;")
    ProjektConnection.Open()
    'establish command object
    ProjektCommand = New OleDbCommand("Select * from Projekt", ProjektConnection)
    'establish data adapter/data table
    ProjektAdapter = New OleDbDataAdapter()
    ProjektAdapter.SelectCommand = ProjektCommand
    ProjektTable = New DataTable()
    ProjektAdapter.Fill(ProjektTable)
    'bind controls to data table
    txtIDProjekt.DataBindings.Add("Text", ProjektTable, "IDProjekt")
    txtCustomer.DataBindings.Add("Text", ProjektTable, "Customer")
    txtModule.DataBindings.Add("Text", ProjektTable, "Module")
    txtProjekt.DataBindings.Add("Text", ProjektTable, "ProjektName")
    txtSerial.DataBindings.Add("Text", ProjektTable, "SerialNo")
    txtOrderType.DataBindings.Add("Text", ProjektTable, "OrderType")
    txtDatum.DataBindings.Add("Text", ProjektTable, "DatumPro")
    txtTotalUhr.DataBindings.Add("Text", ProjektTable, "TotalUhr")
    'establish currency manager
    ProjektManager = DirectCast(Me.BindingContext(ProjektTable), CurrencyManager)
 
    pColorFondo.BackColor = Color.FromArgb(colorFondoQR)
    pColorQR.BackColor = Color.FromArgb(colorQR)
 
    tabFormatoQR.SelectedTab = TabProjekt
    Call SetState("View")
    txtProjekt_TextChanged(sender, e)
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder