Results 1 to 7 of 7

Thread: [RESOLVED] OldDB Insert cmd- source DB password required

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    88

    Resolved [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?

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: OldDB Insert cmd- source DB password required

    what have u defined in ScoreboardConnectionString? Passwords are generally mentioned in connection string.
    Microsoft Techie

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    88

    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.

  4. #4
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: OldDB Insert cmd- source DB password required

    Can you provide the ConnectionString that you are using?
    Microsoft Techie

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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]"

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    88

    Thumbs up Re: OldDB Insert cmd- source DB password required

    PERFECT! That worked perfectly perfect in fact.

    Si, thank you very much.

    I am going to mark this thread as Resolved, but I would really like to know where you dug up that little tidbit… I am guessing an obscure SQL reference manual.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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
  •  



Click Here to Expand Forum to Full Width