incompletefool

New member
Joined
Apr 1, 2009
Messages
4
Programming Experience
Beginner
I am feeling stupid, which doesn't take much these days.
I have a simple program in vb 2005 that generates data. I have created a table in which to store the date (3 columns, 4 if you include the index).
So when I run my program, how do I get the data in the table?
I have literally spent hours frikking around with tableadapter.fill which just leads me to more code and more errors. I am obviously missing something conceptually.
Just seems I ought to be able to say something like TableRow(x,y,z).

Of course, after I get it in there I'd like to view it and get it back out, but one thing at a time.

Help

Thanks:confused:
 
Hi,

I was wondering if your app generates data storing the data into database or something else. Please clarify!

Btw, if it's database e.g. SQL Server I suggest you use a SqlDataReader Class (usage example included) which provides a way of reading a forward-only stream of rows from a SQL Server database.

Hope this helps!
 
I have a program. You click a button.
It executes a Do Until loop, currently set for 4 times.
Nested is a Do While loop, currently set for 30 iterations.
During each iteration a function is called that returns x and y.
I want to save each iteration of x and y and the iteration of the Do Until loop it was produced under.
Towards that end I have created a table.
How do I put (write/update/input/record/populate/whatever) that data into the table?
It can't be all that hard. What am I missing?

I don't know how to be clearer.
I don't need user data entry forms.
I need something that should be more akin to:
Table.NextRow(x, y, UntilLoopIteration)
 
Ok but do you have any database like MSSQL, MySql or MSAccess running?

Beside that, solution of your problem is pretty str8 forward.
First you need to design a table with columns for x and y.

Then you need some SQL code in order to store the x and y values into database.

e.g.
VB.NET:
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim strSQL As String = "Insert INTO myTable(x, y) VALUES(" & x & ", " & y & ")"
        Dim conn As New SqlConnection("connection string")
        Dim cmd As New SqlCommand()
        cmd.Connection = conn
        cmd.CommandType = Data.CommandType.Text
        cmd.CommandText = strSQL
        cmd.Connection.Open()
        Do While expression
            Do While expression
                'set x and y values here
                cmd.ExecuteNonQuery()
            Loop
        Loop
        cmd.Connection.Close()


However you should be familiar with database concepts?
 
The post doesnt seem to indicate wanting to save the data after the program has ended, only how to work with and display data while the app is running. He may actually want to save the data but so far what is mentioned I dont think needs a whole database, I would suggest saving to a file instead unless more data is being saved then is indicated.

A small example of adding data to a dataset/datatable

Dim rowNew as DataRow

rowNew = myDataset.TableName.NewRow
rowNew("Col2Name") = X
rowNew("Col3Name") = Y
myDataset.TableName.Rows.Add(rowNew)

'To view the data within your table in a DataGridView
DataGridView1.DataSource = myDataset.TableName
 
kulrom & Tom-

Thank you both.
Tom's code snippet addresses my immediate frustration.
I knew it had to be relatively simple, but I sure wasn't getting there following "Help" through TableAdapters. It is my unsolicited opinion that something as basic as saving data to a table should have a parallel construction to passing parameters.
I do need a database. I will want to save data after a run and I will have related tables.
I could babble on about having played with VB6 in the past and getting frustrated with Access, but who cares?

When the need to write the current program came up, I figured I needed to learn to deal with an object oriented language so i downloaded VB 2005 Express. It comes with SQL Server Express.

I guess I need to ask for recommendations for Books on VB 2005 and Sql Express so my future questions will be more interesting.

Again, Thank You
 
TableAdapters & DataAdapters have to do with actually transfering the data to & from the actual database. If the info was being queried from the DB instead of a file and/or saved back to the DB afterwards then the Adapters would come into play.

"Pro Ado .Net 2.0" I thought was a very good book as far as specifically explaining working with VB & Sql Server. Not sure if you want something that specific yet or some more general that will explain using each control, how to use a loop etc....
 
I am actually pretty ok with loops and logic and structured programming concepts.
Its the quirks of individual programming languages that drive me nuts, and the fact that unless you ask the question exactly right, Help is no help. And if I knew exactly how to phrase the question I probably wouldn't need to ask the question.

"TableAdapters & DataAdapters have to do with actually transfering the data to & from the actual database. If the info was being queried from the DB instead of a file and/or saved back to the DB afterwards then the Adapters would come into play."

How is the code you gave me different from what you are talking about here?

I'll check out the book.

thanks again,
 
For instance a data adpater would be used to run an sql query which retrieves info from your database and fills it into your dataset or datatable.

The example I provided has nothing to do with the database, it only adds data records directly to your datatable in memory.

Now say you add a whole bunch of new records to your datatable. Eventually your going to want to transfer that data to either a file or database. To send it to the database you again would use a data adapter to do the transfer.
 

Latest posts

Back
Top