Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys.

I am attempting to archive data from one Access Database to another and have managed to get this far :
VB
Dim cp As String = "Microsoft.ACE.OLEDB.12.0;"
Dim da As OleDb.OleDbDataAdapter

Dim DBPath As String = "C:\....\Databases\HVT-HVTPS\DB-TEST"
Dim DBName As String = "\TEST_Test_Commercial_DB.accdb"

Dim ArchiveDBPath As String = "C:\..........\Databases\HVT-HVTPS\DB-TEST"
Dim ArchiveDBName As String = "\TEST_Test_Archive_DB.accdb"

Dim DB_FROM As String = "C:\.......\TEST_Test_Commercial_DB.accdb"
Dim DB_TO As String = "C:\.......\TEST_Test_Archive_DB.accdb"

Dim cnnFrom As New OleDb.OleDbConnection
Dim cnnTo As New OleDb.OleDbConnection

Dim strSQL As String



    cnnFrom.ConnectionString = "Provider=" & cp & " Data Source=" & DBPath & DBName & ";Jet OLEDB:Database Password=xyx;"
    cnnTo.ConnectionString = "Provider=" & cp & " Data Source=" & ArchiveDBPath & ArchiveDBName & ";Jet OLEDB:Database Password=xyz;"

    cnnFrom.Open()
    cnnTo.Open()

    strSQL = "INSERT INTO Archive_Purchase_Order SELECT * FROM Purchase_Order IN '" & DB_FROM & "' WHERE Po_Number = 'DD14-02-003 / 299RV'"
    '                                                                                     ^
    '                                                                              Error appears to be here (In DB_FROM)

    Try
        da.InsertCommand = New OleDbCommand(strSQL, cnnTo)
        da.InsertCommand.ExecuteNonQuery()                 'crashes here with System.Data.OleDb.OleDbException (0x80004005): Not a valid password.
    Catch ex As Exception
        cn.Close()
        MsgBox(ex.ToString)
        Exit Sub
    End Try


The InsertCommand is crashing with a message :
System.Data.OleDb.OleDbException (0x80004005): Not a valid password.

Clearly I am not providing the database password with the path, but I have no idea how to !!

Could anyone please assist.

Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900