944,028 Members | Top Members by Rank

Ad:
Nov 8th, 2009
0

VB6 database Help Required

Expand Post »
how can i create an database dynamically i.e. my code creating database while running taking an user input??

i have seen code like below working

Dim db As Database
Dim ReS As Recordset
Set db = OpenDatabase(App.Path + "\Data\" + Userinput + "\Memo.dat")
Set ReS = db.OpenRecordset("Memo")
ReS.AddNew
ReS("Title") = txtTitle.Text
ReS("Details") = txtDescription.Text


but if i do the same, i get an error - "invalid path"
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
pankaj.garg is offline Offline
69 posts
since Nov 2009
Nov 8th, 2009
0
Re: VB6 database Help Required
Well first off you need to make sure the directory exists by using the dir function and if it does not exist then you need to use the mkdir statement. HOWEVER, if you are on vista or win7 and in the program files directory, you will not be able to use app.path. Instead, use environ("appdata") & "\ProgramName\Data\nameofmdb.mdb.



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Nov 8th, 2009
0
Re: VB6 database Help Required
if the file in same folder
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. (App.Path & "\db1.mdb")
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Nov 10th, 2009
0
Re: VB6 database Help Required
[QUOTE=vb5prgrmr;1041168]Well first off you need to make sure the directory exists by using the dir function and if it does not exist then you need to use the mkdir statement. HOWEVER, if you are on vista or win7 and in the program files directory, you will not be able to use app.path. Instead, use environ("appdata") & "\ProgramName\Data\nameofmdb.mdb.



Good Luck[/QUO

i am on XP...even after i have made the directory...i am not able to create the desired file....do i need to enable any library files or something??
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
pankaj.garg is offline Offline
69 posts
since Nov 2009
Nov 10th, 2009
1
Re: VB6 database Help Required
Don't think so but look at Project>References. You should have these four at the top and in this order...

Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation

Okay, so you are wanting to create an access database and not just open one (as what your code is saying...)

Okay, see post #12 in this thread for an example... http://www.codeguru.com/forum/showthread.php?t=476345

or since you are using DAO start a new project and add the 2.5/3.51 compatability library and then type in...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim DB As DAO.Database
  2. Set DB = DBEngine.CreateDatabase
and with the cursor somewhere in or at the end of createdatabase press F1 to bring up help.



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Nov 11th, 2009
0
Re: VB6 database Help Required
weel theres a function to let the user select a directory, used it to where you save you database to be created. you can also use that to open the database. I think the control is Dialog, opendialog and savedialog box, thats it.

why do you want to create the db during runtime?
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Nov 11th, 2009
0
Re: VB6 database Help Required
why not make function that will open another program which will create a database?
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB-Prime Numbers
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB6 find and replace





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC