|
-
Jul 13th, 2003, 01:06 PM
#1
Thread Starter
Fanatic Member
Opening Database [RESOLVED]
I am trying to open a database using a data control, however, I cannot use the OpenDatabase function. (yes, I am a noobie to VB.) How can I do this?
Code:
' Bring up a load window
cdbDialog.DialogTitle = "Open database. . ."
cdbDialog.Filter = "Database (*.mdb, *.xls)|*.mdb;*.xls"
cdbDialog.FileName = "mydata.xls"
cdbDialog.ShowSave
If (cdbDialog.FileName <> "") Then
' Close the current database
dtaMagicBase.Close
' Open the new database
End If
Last edited by Darkwraith; Jul 18th, 2003 at 03:00 PM.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 14th, 2003, 01:29 AM
#2
-= B u g S l a y e r =-
what kind of datacontrol are you using ? DAODC or ADODC ?
-
Jul 14th, 2003, 12:26 PM
#3
Thread Starter
Fanatic Member
I believe it is DAODC (the control that has the default name of Data1. )
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 14th, 2003, 05:57 PM
#4
Thread Starter
Fanatic Member
I could use the ADODC if need be. I was thinking of putting the database in Access anyway...
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 17th, 2003, 06:29 PM
#5
Thread Starter
Fanatic Member
I decided to go with an Access database and a data control, but I still cannot get back the database after I close it.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 18th, 2003, 12:42 AM
#6
-= B u g S l a y e r =-
Morning Darkwraith, sorry to say, but I do not have any good suggestions on the subject.... (I don't use bound controls)
Before you go further with bound data controls, you should read this : http://www.vbrad.com/pf.asp?p=Articl...nding_evil.htm
-
Jul 18th, 2003, 12:54 AM
#7
Thread Starter
Fanatic Member
Good Morning (or night w/e the case may be) Peet.
I dropped the data control because I found that the FAQ was actually more helpful than my books and converted to ADODC.
If you have something for ADODC to open an Access database, it would be helpful and much appreciated.
The code is pretty much the same.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 18th, 2003, 01:11 AM
#8
-= B u g S l a y e r =-
oh its morning 
VB Code:
Dim sConnString As String
' Bring up a load window
cdbDialog.DialogTitle = "Open database. . ."
cdbDialog.Filter = "Database (*.mdb, *.xls)|*.mdb;*.xls"
cdbDialog.FileName = "mydata.xls"
cdbDialog.ShowSave
If (cdbDialog.FileName <> "") Then
' Open the new database
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & cdbDialog.FileName & ";Persist Security Info=False"
dtaMagicBase.ConnectionString = sConnString
dtaMagicBase.RecordSource = "Consumables"
dtaMagicBase.Refresh
End If
does the job
-
Jul 18th, 2003, 09:02 AM
#9
Thread Starter
Fanatic Member
Thx! It works.
Question, though. Do I have to explicitly tell it to close or will it implicitly free whatever resources it took to open the previous database?
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 18th, 2003, 01:13 PM
#10
-= B u g S l a y e r =-
Dont think you have to close it. If you test it, and then open another db without the app crashing, then the new connectionstring has reset the data object.
-
Jul 18th, 2003, 02:59 PM
#11
Thread Starter
Fanatic Member
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|