Jump to content
Can't remember your login details? Read more... ×
Focus

.net2005 database issue

Recommended Posts

Hi, if this has already been posted please lock (I did search).

 

I'm writing an application that stores data from variables into a local Ms Access database in vb.net 2005.

So far I can get the application to commit changes made in the dataset to the database that I make manually myself using the datagrid, however when I try to assign the value of an array element to the table (PIDData) I get the error "Property 'VehicleSpeedColumn' is 'ReadOnly'."

 

These are the statements I use to attempt to copy data into the dataset's table:

CarLoggerDBDataSet.PIDData.VehicleSpeedColumn = VehicleSpeed(Commit) 'error occurs here

CarLoggerDBDataSet.PIDData.Rows.Add()

Commit = Commit + 1

 

Every readonly property that I can find is set to false.

Also when I type "CarLoggerDBDataSet.PIDData" I get a list of all of the fields in the dataset (as well as other stuff) but the names for field names always ends in "column".

 

Is there something that I'm doing wrong or should this work?

My OS is Vista Home Premium.

 

Any info would be greatly appreciated.

Share this post


Link to post
Share on other sites

A column represents a column. 'huh' I hear you say...

 

You are writting a field value to an instance of a column. Think about how a DataTable works for a moment. A DataTable is made up of Rows and Columns. Each row contains multiple cells, representing each column in the table, while each Column contains multiple cells representing that attribute for each row. What you're doing in the above assignment is assigning a VehicleSpeed to a Column that contains multiple cells.

 

What you need to do is add the VehicleSpeed to a cell, if you want to think like tables, or to the the VehicleSpeed attribute for a particular row.

 

First select the row you want to work with. For example, to select the first row in the table:

Dim row as PIDDataRow = CarLoggerDBDataSet.PIDData(0)
Now update the attribue on that row:

row.VehicleSpeed = VehicleSpeed(Commit)
Commit = Commit + 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×