Visual Basic and Databases... help! (1 Viewer)

ReverseSt4r

The real Scribe.
Joined
Jul 17, 2007
Messages
8
Location
Hawkesbury Heights
Gender
Male
HSC
2008
Hey guys,

I'm in yr11 and I'm having trouble with an assessment task. We need to create a software solution in Visual Basic 6.0, and I've decided to make a database which displays information on a (pretend) CD store's sales and inventory details. The database will then open in a VB6 form.

I set up the table in the database with all the info I want, and then I made the form, and put in the following code:

---
Dim rsVIEW As Recordset
Dim dbVIEW As Database
---
Private Sub Form_Load()
Set dbVIEW = OpenDatabase("C:\Documents and Settings\Owner\My Documents\SDD Major Project\AXIS\DATABASE\db1.mdb")
Set rsVIEW = dbVIEW.OpenRecordset("Table1", dbOpenDynaset)
If Not rsVIEW.EOF Then rsVIEW.MoveFirst
Do While Not rsVIEW.EOF
lst_Records.AddItem rsVIEW!Name
lst_Records.ItemData(lst_Records.NewIndex) = rsVIEW!ID
rsVIEW.MoveNext
Loop
End Sub
---

The program is supposed to fill up listbox "lst_Records" with the records from the table. But whenever I run the program, VB has a tantrum and says:

---
Run-time error '3343':

Unrecognized database format 'C:\Documents and Settings\Owner\My Documents\SDD Major Project\AXIS\DATABASE\db1.mdb'.
---

What do I do? Can you guys help?

~ReverseSt4r
 

meowz0r

New Member
Joined
Sep 10, 2006
Messages
21
Location
Sydney
Gender
Male
HSC
2007
ReverseSt4r said:
Hey guys,

I'm in yr11 and I'm having trouble with an assessment task. We need to create a software solution in Visual Basic 6.0, and I've decided to make a database which displays information on a (pretend) CD store's sales and inventory details. The database will then open in a VB6 form.

I set up the table in the database with all the info I want, and then I made the form, and put in the following code:

---
Dim rsVIEW As Recordset
Dim dbVIEW As Database
---
Private Sub Form_Load()
Set dbVIEW = OpenDatabase("C:\Documents and Settings\Owner\My Documents\SDD Major Project\AXIS\DATABASE\db1.mdb")
Set rsVIEW = dbVIEW.OpenRecordset("Table1", dbOpenDynaset)
If Not rsVIEW.EOF Then rsVIEW.MoveFirst
Do While Not rsVIEW.EOF
lst_Records.AddItem rsVIEW!Name
lst_Records.ItemData(lst_Records.NewIndex) = rsVIEW!ID
rsVIEW.MoveNext
Loop
End Sub
---

The program is supposed to fill up listbox "lst_Records" with the records from the table. But whenever I run the program, VB has a tantrum and says:

---
Run-time error '3343':

Unrecognized database format 'C:\Documents and Settings\Owner\My Documents\SDD Major Project\AXIS\DATABASE\db1.mdb'.
---

What do I do? Can you guys help?

~ReverseSt4r
I'm not too sure if I can help but i'll try....I made a pizza ordering program where the person ordered a pizza and when it was ordered it saved it as an entry to the database.

Have you tried googling the error? Unrecognized database format says to me that your database isn't being recognised (duh! haha).

" The program is supposed to fill up listbox "lst_Records" with the records from the table." To do this you'd have to firstly import the data into VB with a dataset, ie take the data from the database and plonk it so it's accessible to VB. Are you sure a listbox is the best way to represent it the records? If it's a record, by definition it has multiple fields, ergo how can this be represented in a list box?

Have you considered using a datagridview to show the data? If you bind it to a dataset, it automatically labels the columns/rows of ur database and populates it with what's in the database. If you can find it, there's a chapter in "Build a program NOW! MIcrosoft Visual Basic 2005 Express Edition" (i used express to build mine) which takes you step by step through adding a database to your application - perhaps there's something online like it?

Hope it helped...
 

Zatts

New Member
Joined
Nov 6, 2004
Messages
14
Location
Sydney, Australia
Gender
Male
HSC
2005
ReverseSt4r said:
Unrecognized database format 'C:\Documents and Settings\Owner\My Documents\SDD Major Project\AXIS\DATABASE\db1.mdb'.
What version of Microsoft Access (assuming you used Access) did you use?
 

boblemur

New Member
Joined
Sep 17, 2007
Messages
16
Gender
Male
HSC
2007
hey maybe a bit late.

ok i dono wat db format vb wants but what i would do if i was you....

forget using the database all together...

use a diff file(thus demonstrating that u can use file access) will get u more marks anywayz....

u can export the table from access so its comma delimited

say u have 5 feilds if u

for i = 0 to 4
input #1,Feild(i)
next

then repeat this for each record

or if u want to take the entire record....

line input #1,feild(i) (only need to do this once for each record)

but that way u can use ms flex grid control(very easy to use)

show u know how to handel a file and i think this would be alot more helpful

markswise at least....the db will just be fiddly to make it work and it wont look that impressive



hope this helps....for any help email me n_d_89@hotmail.com
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top