Lost path

tripes

Member
Joined
Apr 16, 2009
Messages
18
Programming Experience
Beginner
hi i have a program that uses ms access database in vb.net 2003, when i run the program it seems to work fine but if i press a button that uses an openfile dialogbox and try to open again my database the program crashes... it seems that is losing the path... can anyone help me pls? :(
 
the error that gives me is "An unhandled exception of type "System.Data.OleDB.OleDBexception" occured in system.data.dll" on the line "me.adapter.fill(me.dataset.tablename)"
 
:)there that it sais Data source="path" i have inserted the whole path of my database and it works fine now, but i am afraid that it will not work on other pc because path will not be the same...how can i fix it?
 
Let me check I understand:

You ask the user to pick a DB file
You put the path to the file in the connection string (DataSource='<path>')

Why would you think this would fail on another machine?
 
this does not work because i haven't used connection string i have used wizards to create my dadabase connection... and the Data source=""path"" is in the generated code
 
my code in the generated code is like this:
'connectionMainForm
'
Me.connectionMainForm.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDBatabase L" & _
"ocking Mode=1;Jet OLEDBatabase Password=;Data Source=""C:\Users\Valued Customer" & _
"\Desktop\test2 - Copy\bin\db12.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft." & _
"Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Jet OLEDB:Global B" & _
"ulk Transactions=1;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLE" & _
"DB:Create System Database=False;Jet OLEDBon't Copy Locale on Compact=False;Jet" & _
" OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Data" & _
"base=False"
 
so, take it out and replace it with a token that you replace at runtime?

VB.NET:
Dim connStrTemplate as String = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDBatabase L" & _
"ocking Mode=1;Jet OLEDBatabase Password=;Data Source=""{PATH}"";Jet OLEDB:Engine Type=5;Provider=""Microsoft." & _
"Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Jet OLEDB:Global B" & _
"ulk Transactions=1;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLE" & _
"DB:Create System Database=False;Jet OLEDBon't Copy Locale on Compact=False;Jet" & _
" OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Data" & _
"base=False" 

Me.connectionMainForm.ConnectionString = connStrTemplate.Replace("{PATH}", PATH_TO_DB_MAYBE_FROM_USER_FILE_CHOOSER)
 

Latest posts

Back
Top