[VB.NET] OLE, OLE, You give me grief yet again...

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

[VB.NET] OLE, OLE, You give me grief yet again...

Post by thegamefreak0134 »

This is really starting to bother me...

I can get my MS Access Database to show up in VB.NET. (I can connect to it. Whoopie.) I set up an OleDbDataAdapter, and set the table mappings to basically return the whole table. I only have a few slight issues. Like not being able to see the data at all.

How on earth am I actually supposed to access this information? I basically want to read the entire database contents into a series of arrays, which will be easier for me to work with. Does someone know how to fo this? (I have no code at all because I don't know where to start. I have simply set up the database connection info in the IDE.)

Thanks a bunch to anyone who can help me out. I need to be able to compete with this info in two days time...

-thegamefreak0134
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

As you can see from the blurb, data access with Windows Forms is pretty much just dragging and dropping data access components onto a form. My experience thus far has been pretty minimal so I can't really help you beyond saying if you dump a DataGrid onto a form it walks you through connecting to the data source (in this case, you'd pick your Access database). Have you tried that, and seen if that's retrieving data from your database?

If you can't get it working I'll have a go when I'm near Visual Studio and send you a demo.
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

Oh piddle. I'm not entirely sure which version of VB.NET they will be using at contest. I would naturally assume 2005, but one can never be too sure. Since the methods are likely backwards compatible, when you are near the computer could you try to use only methods that are available in 2003? (I know it can still be done of course.)

I know this is getting a bit specific, but well... I've been trying to get this to work for several years now. I know I can just import sample data of my own if I need to, but I can't get full credit (and a better chance at making the cut for Nationals again) unless I can actually read data...

Grr... I'm installing 2005 over here of course, I like the new features. However I may be stuck with the older 2003 at contest, which is why I ask.

-thegamefreak

PS: The OleDbDataAdapter has a "fill" function as well as some insert and delete functions, which just scream database access to me. However, I cannot seem to make these functions work. (They call for a DataTable type, but generate a "value cannot be null" error, which baffles me to no end.) It's not like I haven't been trying...
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

*GASP* I ... I ... IT WORKS.... sort of...

OK, OK, I officially figured out that the tooltip has a typo. It wanted me to import a DataSet, not a Data Table. No biggie.

OK, so I got my grid to show my access table by setting it's data source to:

HappyData.Tables(0) 'Yes, it's happy.

Now I need to go a bit farther, and it's stumping me again. Assuming that the table crud is taken care of (Yes, Finally!!! w00t) how do I go about doing basic table stuff?

Basically, I need to set which record I'm viewing (which I assume is indexed by the primary key I set?), read out the number of records in the table, and then promptly loop through the records and copy the data into lists. Easy enough, but I'm still a little stuck with these odd commands. (Working out SQL in php was hard enough, mind you... and that was with considerable help with a friend.)

-thegamefreak

*EDIT* Gasp again!

Well ben, I actually managed to figure this one out. Happy for me. Note the following:

Code: Select all


        happydata = New DataSet("Table")
        HappyCow.Fill(happydata, "Table")
        DataGrid1.DataSource = happydata.Tables(0)
        Dim happystuff() = happydata.Tables(0).Rows(0).ItemArray()
        TextBox1.Text = happystuff(2)
This causes textbox1 to essentially contain the data in the 3rd field of the 1st record in the datbase. (base 0 system, rather rare for VB for some reason, but it makes me happy.)

Sorry for the pesterance. Your information was actually quite useful though, and I will definately look into it if they use 2005. (That looks a lot easier than what I had to do to connect to this one...)

PS: It works it works it works it works it woooooorrrkks!!! (commence with the dancing about the room)
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Accessing a database could be done easier with the use of .Read() statements... but that's just me.
Image
Post Reply