| | |
VB6 database Help Required
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 17
Reputation:
Solved Threads: 0
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"
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"
•
•
Join Date: Mar 2009
Posts: 859
Reputation:
Solved Threads: 157
0
#2 32 Days Ago
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
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
0
#3 31 Days Ago
if the file in same folder
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
(App.Path & "\db1.mdb")
I like sword. Attack or Defense.
•
•
Join Date: Nov 2009
Posts: 17
Reputation:
Solved Threads: 0
0
#4 30 Days Ago
[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??
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??
•
•
Join Date: Mar 2009
Posts: 859
Reputation:
Solved Threads: 157
1
#5 30 Days Ago
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...
and with the cursor somewhere in or at the end of createdatabase press F1 to bring up help.
Good Luck
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)
Dim DB As DAO.Database Set DB = DBEngine.CreateDatabase
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
0
#6 29 Days Ago
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?
why do you want to create the db during runtime?
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
0
#7 29 Days Ago
why not make function that will open another program which will create a database?
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
![]() |
Similar Threads
- SMS VB6 database (Visual Basic 4 / 5 / 6)
- VB6 Database Program (Visual Basic 4 / 5 / 6)
- Help in Access-VB6.0 query (Visual Basic 4 / 5 / 6)
- Loading pictures on ms and vb6 database (Visual Basic 4 / 5 / 6)
- VB6 & database (Visual Basic 4 / 5 / 6)
- "Error in linking List box with the VB6.0 database" (Visual Basic 4 / 5 / 6)
- Choose suitable database package (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: VB-Prime Numbers
- Next Thread: VB6 find and replace
| Thread Tools | Search this Thread |
.net 429 2008 access acquisition age amd analyst application array asp asp.net assignment avatar backup basic bigbrother bluegene breach business c# check chips computing connectingtodatabaseinuse connection daniweb data database databaseconnection databasesearch dataset development dos dropdown economy energy enter enterprise enterprisesoftware form hardware hp ibm ibm.news images intelibm java linux medicine memory microsoft myregfun mysql news objectinsert openoffice opensource operatingsystem oracle pc php programmer ps3 recession record redhat russia search security server servlet single sql sqlite sqlserver structures sun supercomputer supercomputing survey table technology trends ubuntu uk update vb vb.net vb6 vb6.0 visual visualbasic visualbasic.net visualstudio web windows working wpf x86






