Converting vb6 to vb.net - openfiledialog question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lisa Martin
    New Member
    • Sep 2007
    • 2

    Converting vb6 to vb.net - openfiledialog question

    Ok so this is day 2 my first programming job. What I have done is to convert a vb6 program to vb.net... no problem. Today I was asked to "add a db pointer" to one of the forms to make sure that the db I am working with is not the live one the company used...merely a copy on my hard drive. That was easy but I realized that there was no way to change the database should the user decide to do so so I added an openfiledialog so the user could make their own choice. My problem is that I cant figure out how to use the user's choice instead of the main db that the pointer is pointing to.

    On one form (barcodes) I have the following code (including my attempts which are commented out:
    Private Sub FrmBarCodeMain_ Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArg s) Handles MyBase.Load
    Dim DB As DAO.Database
    'UPGRADE_WARNIN G: Arrays in structure RS may need to be initialized before they can be used. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?ke yword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'
    Dim RS As DAO.Recordset
    Dim myResult As DialogResult
    'Dim fileResult As DialogResult

    On Error GoTo ErrorTrap
    'UPGRADE_WARNIN G: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?ke yword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
    If Dir(My.Applicat ion.Info.Direct oryPath & "\BarCodes.mdb" ) = "BarCodes.m db" Then
    myResult = MsgBox(My.Appli cation.Info.Dir ectoryPath & "\BarCodes. mdb" & (Chr(13)) & "Is this the correct database?", MsgBoxStyle.Yes No)
    If myResult = Windows.Forms.D ialogResult.No Then
    OpenFileDialog1 .ShowDialog()
    'fileResult = OpenFileDialog1 .FileName

    End If
    'If Dir(My.Applicat ion.Info.Direct oryPath & "\BarCodes.mdb" ) = "BarCodes.m db" Then
    ' myResult = MsgBox(My.Appli cation.Info.Dir ectoryPath & "\BarCodes. mdb" & (Chr(13)) & "Is this the correct database?", MsgBoxStyle.Yes No)
    ' If myResult = Windows.Forms.D ialogResult.No Then
    ' ReadSetupDB()
    ' End If
    ReadSetupDB()

    Then on the other form (barcodesubs) there is the following code:
    Sub ReadSetupDB()
    Dim SetupDB As DAO.Database
    'UPGRADE_WARNIN G: Arrays in structure RS may need to be initialized before they can be used. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?ke yword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'
    Dim RS As DAO.Recordset
    Dim I As Short

    On Error GoTo ErrorTrap
    SetupDB = DAODBEngine_def inst.OpenDataba se(My.Applicati on.Info.Directo ryPath & "\BarCodes.mdb" )

    If AbortFlag <> 0 Then
    MsgBox(Message & "Aborting!" , MsgBoxStyle.Cri tical)
    End
    End If

    RS = SetupDB.OpenRec ordset("Setup")

    If AbortFlag <> 0 Then
    MsgBox(Message & "Aborting!" , MsgBoxStyle.Cri tical)
    End

    End If

    Now this is not all of the code but I think it is all that would be needed. Anyway, what is happening is that everything appears to be fine but the user's choice from the openfiledialog wont open. No matter what I do that silly barcodes.mdb opens! Any suggestions?
Working...