473,378 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.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
0 1699

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

Similar topics

3
by: violin wang | last post by:
hi I wrote a windows based program.The main UI named form_base has a button "btn1".In btn1`s click event handler I used ShowDialog(this) to show another form named form_test.form_test also has a...
7
by: C# newbie | last post by:
Hello, using openfiledialog, how can I retrieve the path ? thx
3
by: bobrad | last post by:
MAYBE SOMEBODY CAM HELP I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM DIALOG OpenFileDialog openFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = " Access...
4
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in...
8
by: e-mid | last post by:
why does not openFileDialog have closed event? i want to do something; as soon as the dialog closes. is there a way to do this?
6
by: barbara_dave | last post by:
Hi, All, I want to use the openfiledialog to open different extension files in different directory( only one type files at one time). I set the OpenFiledialog InitialDirectory and Filter...
8
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and...
3
by: Tony Johansson | last post by:
Hello! The object called dlgOpenFile is of type OpenFileDialog. In this example the eventhandler OnFileOpen is called when the Open File in a menu is clicked. Here we call the OpenFileDialog...
2
by: Peted | last post by:
Hi i have a circumstance where a user unzips a file, with a certain layer of directories to get to a textfile. So in any directory on the HDD they may end up with something like ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.