By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,996 Members | 896 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,996 IT Pros & Developers. It's quick & easy.

Saving/loading a structured array from an Access database

P: n/a
This may reveal my poor programming skills, but here goes...

I'm building a pricing tool for my business. I'm nearing the end of the
project, and I've been asked to be able to save quotes in some sort of
database (Major Feature Creep). For each quote, I've got two kinds of
variables. The first are global for the quote, such as

numQuoteRows
QuoteFinalCost
CustomerID

Secondly, I've got the quote rows stored in a structured array, for example:

quoteRow(3).widgetHeight is the height of quote row 3 widget.
quoteRow(6).widgetQuantity is the number of widgets in quote row 6

The question is, how can load & save this info into an Access database. I
figure I can have one table with the global quote information, and one with
the quote rows, but I'm not sure how to feed the info to & from the database.

Please bear in mind I first picked up an intro to VB.NET book a little over
a year ago, and this is my first massive programming project. I've got Access
databases for customer info and all the widget pricing & configuration, so
descriptions of an Access interface would hopefully work. Many thanks for any
advice that you can provide.

--
Cary
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Cary,

The first thing you should do in my opinion is make from your array a
datatable.

Than it is so very simple doing what you ask.

In the most simple approach do you need than

An oledbconnection
dim conn as new oledb.oledbconnection(myconnectionstring)

For you connectionstring
http://www.connectionstrings.com/

a datatable
dim dt as new datatable

a dataadapter
dim da as new oledbdataadapter("Select * from mytable",conn)
da.fill(datatable)

an oledbcommandbuilder
dim cmb as new oledb.oledbcommandbuilder(da)
'this one builds the command and probably you never use it further however
with this the commands are build (when your selectstrings becomes complex
you cannot use it anymore however with your 2 fields it is probably great).

And when you have done your changes you do
da.update(datatable)

And then when you have no concurrent users and set all the error trapping
needed using try and catch, you are almost ready

I hope this helps?

Cor

"Cary" <Ca**@discussions.microsoft.com>
This may reveal my poor programming skills, but here goes...

I'm building a pricing tool for my business. I'm nearing the end of the
project, and I've been asked to be able to save quotes in some sort of
database (Major Feature Creep). For each quote, I've got two kinds of
variables. The first are global for the quote, such as

numQuoteRows
QuoteFinalCost
CustomerID

Secondly, I've got the quote rows stored in a structured array, for
example:

quoteRow(3).widgetHeight is the height of quote row 3 widget.
quoteRow(6).widgetQuantity is the number of widgets in quote row 6

The question is, how can load & save this info into an Access database. I
figure I can have one table with the global quote information, and one
with
the quote rows, but I'm not sure how to feed the info to & from the
database.

Please bear in mind I first picked up an intro to VB.NET book a little
over
a year ago, and this is my first massive programming project. I've got
Access
databases for customer info and all the widget pricing & configuration, so
descriptions of an Access interface would hopefully work. Many thanks for
any
advice that you can provide.

--
Cary

Nov 21 '05 #2

P: n/a


"Cary" <Ca**@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
This may reveal my poor programming skills, but here goes...

I'm building a pricing tool for my business. I'm nearing the end of the
project, and I've been asked to be able to save quotes in some sort of
database (Major Feature Creep). For each quote, I've got two kinds of
variables. The first are global for the quote, such as

numQuoteRows
QuoteFinalCost
CustomerID

Secondly, I've got the quote rows stored in a structured array, for
example:

quoteRow(3).widgetHeight is the height of quote row 3 widget.
quoteRow(6).widgetQuantity is the number of widgets in quote row 6

The question is, how can load & save this info into an Access database. I
figure I can have one table with the global quote information, and one
with
the quote rows, but I'm not sure how to feed the info to & from the
database.

Please bear in mind I first picked up an intro to VB.NET book a little
over
a year ago, and this is my first massive programming project. I've got
Access
databases for customer info and all the widget pricing & configuration, so
descriptions of an Access interface would hopefully work. Many thanks for
any
advice that you can provide.

--
Cary


Taking this from the very top...
As I understand it.

You have a 1 to many relationship between quote and rows.
So you want 2 tables

Quotes
Quote_Rows

You need to identify what Rows go with a quote, so you need the key to
Quotes as a field in Quote_Rows.
You can then do a join between them with your sql/query.

Quotes
Quote_Id ( Set as primary key )
whatever other fields

Quote_Rows
Quote_Row_Id ( As primary key )
Quote_Id
description
height
width
quantity
whatever other fields

Go into the relationships thing, add both tables and define the relationship
between the two.

I would suggest if you've done any access work then maybe you should stick
to that.

In access.
The simplest way is a subform for the rows in a form for the quotes.
You do that by designing a form for rows, set it to continuous form as
default view.
Stick all the data on one line in the detail section and size everything
else down if you can.
Make the form header and footer visible.
Put any totals fields in the footer as calculated fields, setting the
source to =sum(quote_row_whatever).
Stick field headings in the header.

Design your Quote screen.
Stick your fields on and get it looking OK ex the rows.
Set it to single form default view.
Then, drag and drop the row screen onto the quote screen.
It'll sort of automagically create the links between them.

--
Regards,
Andy O'Neill
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.