|
-
Nov 16th, 2008, 12:19 PM
#1
Thread Starter
Lively Member
[RESOLVED] OldDB Insert cmd- source DB password required
In trying to update an ACCESS2003 database from VB2005 using OleDB, I have run into a problem of needing to provide a password to access the source database when using the INSERT command. Here is the code I am using to move the data.
Code:
If UpdateRequired = True Then
'Old Database exists... Repopulate the new database
Dim strSQL As String
Dim conString As String = My.Settings.ScoreboardConnectionString
Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(conString)
Dim command As OleDb.OleDbCommand
strSQL = "INSERT INTO tbl_GameData "
strSQL = strSQL & "Select * From tbl_GameData in " & "'" & StrPath & "\" & SourceDBFileName & "'"
Console.WriteLine(strSQL)
command = New OleDb.OleDbCommand(strSQL, conn)
conn.Open()
command.ExecuteNonQuery()
conn.Close()
conn.Dispose()
End If
Is there a way to provide the password the the source database or will need to open a second connection and use a different INSERT strategy?
-
Nov 17th, 2008, 06:26 AM
#2
Fanatic Member
Re: OldDB Insert cmd- source DB password required
what have u defined in ScoreboardConnectionString? Passwords are generally mentioned in connection string.
-
Nov 17th, 2008, 07:50 AM
#3
Thread Starter
Lively Member
Re: OldDB Insert cmd- source DB password required
The ScoreboardConnectionString works for the local database. The entire routine works IF the password is removed from the remote database.
What is needed is a way to pass the password details for the Source (remote) database with the SQL statement.
-
Nov 17th, 2008, 09:16 AM
#4
Fanatic Member
Re: OldDB Insert cmd- source DB password required
Can you provide the ConnectionString that you are using?
-
Nov 17th, 2008, 10:12 AM
#5
Re: OldDB Insert cmd- source DB password required
The connection string is completely irrelevant in this case - the problem is not connecting to the database, but getting the database itself to connect to another one.
Based on previous tests, rather than using IN for that, to be able to use a password you need to use different syntax, eg:
Code:
strSQL = strSQL & "Select * From [MS Access;DATABASE=" & StrPath & "\" & SourceDBFileName & ";Uid=admin;Pwd=password;].[tbl_GameData]"
-
Nov 17th, 2008, 08:18 PM
#6
Thread Starter
Lively Member
-
Nov 18th, 2008, 10:47 AM
#7
Re: [RESOLVED] OldDB Insert cmd- source DB password required
Unfortunately I'm not sure where I found it originally, presumably on the forums somewhere - or perhaps on another unofficial site.
I keep a bookmark to the thread where I first discovered it/worked it out: http://www.vbforums.com/showthread.p...99#post2585899
.. but I didn't mention where I found it (just that I haven't found any official documentation).
I eventually managed to find official documentation for the IN syntax, which is why I have added it to the Database Development FAQs/Tutorials (at the top of this forum), but unfortunately I still haven't found anything for this syntax.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|