473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting vb6 to vb.net - openfiledialog question

2 New Member
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?
Sep 11 '07 #1
0 1724

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

Similar topics

3
1578
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 button btn2 and I added a openfiledialog in form_test.In btn2 click event handler I used ShowDialog(this) to show openfiledialog. When I ran the program, I found that when the openfiledialog returned, the form_test would close automatically and...
7
2216
by: C# newbie | last post by:
Hello, using openfiledialog, how can I retrieve the path ? thx
3
360
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 (*.mdb)|*.mdb|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) DataBaseLocation.Text = openFileDialog.FileName;
4
8009
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 Explorer i am getting error saying that cannot delete that folder as some process is using it. After that i selected a file from the same folder in OpenFileDialog. When i tried to delete the folder after selecting the file also it is giving the...
8
6043
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
3023
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 property for ".dat" files at first time, it works. When I try to use openfiledialog to set different InitialDirectory an different Filter property for ".txt" files at second time, I got frozen window. Even I added code to dispose openfiledialog after...
8
6101
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 only the files I want to see appear in the file list box. When I change the filter to one of the other filters, all the files in the list disappear. If I then manually type a filter into the "Filename" textbox, then the files appear and the filter...
3
2787
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 and select a filename to be opened and then if the Open button is selected we call the OpenFile method.
2
4311
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 dir1/dir2/dir3/dir4/dir5/file.txt
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.