By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

Converting vb6 to vb.net - openfiledialog question

P: 2
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.EventArgs) Handles MyBase.Load
Dim DB As DAO.Database
'UPGRADE_WARNING: 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?keyword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'
Dim RS As DAO.Recordset
Dim myResult As DialogResult
'Dim fileResult As DialogResult

On Error GoTo ErrorTrap
'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
If Dir(My.Application.Info.DirectoryPath & "\BarCodes.mdb") = "BarCodes.mdb" Then
myResult = MsgBox(My.Application.Info.DirectoryPath & "\BarCodes.mdb" & (Chr(13)) & "Is this the correct database?", MsgBoxStyle.YesNo)
If myResult = Windows.Forms.DialogResult.No Then
OpenFileDialog1.ShowDialog()
'fileResult = OpenFileDialog1.FileName

End If
'If Dir(My.Application.Info.DirectoryPath & "\BarCodes.mdb") = "BarCodes.mdb" Then
' myResult = MsgBox(My.Application.Info.DirectoryPath & "\BarCodes.mdb" & (Chr(13)) & "Is this the correct database?", MsgBoxStyle.YesNo)
' If myResult = Windows.Forms.DialogResult.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_WARNING: 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?keyword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'
Dim RS As DAO.Recordset
Dim I As Short

On Error GoTo ErrorTrap
SetupDB = DAODBEngine_definst.OpenDatabase(My.Application.In fo.DirectoryPath & "\BarCodes.mdb")

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

RS = SetupDB.OpenRecordset("Setup")

If AbortFlag <> 0 Then
MsgBox(Message & "Aborting!", MsgBoxStyle.Critical)
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?
Sep 11 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.