使用dataadapter.insert命令提供Access数据库密码 [英] Provide Access database password with dataadapter.insertcommand

查看:91
本文介绍了使用dataadapter.insert命令提供Access数据库密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。



我正在尝试将数据从一个Access数据库存档到另一个Access数据库并且设法实现这一目标:

Hi guys.

I am attempting to archive data from one Access Database to another and have managed to get this far :

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





InsertCommand崩溃并显示一条消息:

System.Data.OleDb.OleDbException(0x80004005):无效密码。



显然我没有提供数据库密码和路径,但我不知道如何!!



有人可以帮忙。



谢谢



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

推荐答案

这篇关于使用dataadapter.insert命令提供Access数据库密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆