none
Exportation base dbf vers base access VB 2010 RRS feed

  • Question

  • Bonjours
    je voudrais exporter les données d'une base dbf vers une base access mais il y a un problème qui m’énerve sachant que j'ai pas trouver la cause voici mon code:

    Imports System.Data.OleDb
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim conDBF As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\ICI\Desktop\Nouveau dossier (4)\Nouveau dossier\Nouveau dossier\;Extended Properties=dBASE 5.0;")
            Dim conAcc As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\ICI\Desktop\Nouveau dossier (4)\Nouveau dossier\Nouveau dossier\depart.accdb")
            Dim cmdDBF As New OleDb.OleDbCommand
            Dim cmdAcc As New OleDb.OleDbCommand
            Dim Field1 As New OleDb.OleDbParameter
            Dim Field2 As New OleDb.OleDbParameter
            With cmdDBF
                .CommandType = CommandType.Text
                .CommandText = "SELECT * FROM DEPART"
                .Connection = conDBF
            End With
            With cmdAcc
                .CommandType = CommandType.Text
                .CommandText = "INSERT INTO DEPART (field1, field2) VALUES(?,?)"
                .Connection = conAcc
                .Parameters.Add(Field1)
                .Parameters.Add(Field2)
            End With
            conDBF.Open()
    
            Dim rdr As OleDb.OleDbDataReader = cmdDBF.ExecuteReader
            While rdr.Read
                conAcc.Open()
                Field1.Value = rdr(0)
                Field2.Value = rdr(1)
                cmdAcc.ExecuteNonQuery()
                conAcc.Close()
            End While
            conDBF.Close()
    
        End Sub


    et voici le message d'erreur




    Krichi Bilel

    jeudi 16 janvier 2014 14:49

Réponses

Toutes les réponses