Answered by:
Local DataBase Help

Question
-
Hello everyone,
I am making a project that saves the information recieved by a serial port in a database. Then the information must be sent to the table. And finally shown on a grid view.
I have seen local data tutorials but they add data manually by a Binding Navigator and by a Data Grew View, but how is it possible to add data automatically by code?
Thanks,
Albert
Sunday, January 6, 2013 4:52 PM
Answers
-
Albert,
How are you setting up your database? Are you using the Wizard? If so it will add a DataSet, a BindingSource, and a TableAdapter.
Adding data to it is pretty simple:
Dim nr As MyDataSet.MyDataTableRow = MyDataSet.MyDataTable.NewMyDataTableRow
With nr
.MyField1 = whatever
.MyField2 = whatever
.MyField3 = whatever
End WithMyDataSet.MyDataTable.Rows.Add(nr)
If MyDataSet.MyDataTable.GetChanges IsNot Nothing Then
' Now use the table adapter's .Update method
End IfObviously pseudo-code but hopefully that's close.
Please call me Frank :)
- Proposed as answer by Mike Feng Monday, January 7, 2013 11:56 AM
- Marked as answer by Albert Nieto Wednesday, January 9, 2013 4:34 PM
Sunday, January 6, 2013 5:19 PM
All replies
-
Albert,
How are you setting up your database? Are you using the Wizard? If so it will add a DataSet, a BindingSource, and a TableAdapter.
Adding data to it is pretty simple:
Dim nr As MyDataSet.MyDataTableRow = MyDataSet.MyDataTable.NewMyDataTableRow
With nr
.MyField1 = whatever
.MyField2 = whatever
.MyField3 = whatever
End WithMyDataSet.MyDataTable.Rows.Add(nr)
If MyDataSet.MyDataTable.GetChanges IsNot Nothing Then
' Now use the table adapter's .Update method
End IfObviously pseudo-code but hopefully that's close.
Please call me Frank :)
- Proposed as answer by Mike Feng Monday, January 7, 2013 11:56 AM
- Marked as answer by Albert Nieto Wednesday, January 9, 2013 4:34 PM
Sunday, January 6, 2013 5:19 PM -
Thank you very much!
This is what I was looking for. Now I'm working on table adapter's, as I never worked with it before, but seems easy. Thank you again!
Albert
Wednesday, January 9, 2013 4:36 PM -
Thank you very much!
This is what I was looking for. Now I'm working on table adapter's, as I never worked with it before, but seems easy. Thank you again!
Albert
Glad it helped!
Please call me Frank :)
Wednesday, January 9, 2013 5:33 PM -
I did it and it works perfect! :)
I have another question. All columns are numeric, except one, that is datatime. It is showed in my form as a DateTimePicker. What I want to do is that when I pick a date, all other columns show all the data of that day. Is that possible?
Wednesday, January 9, 2013 6:45 PM -
I did it and it works perfect! :)
I have another question. All columns are numeric, except one, that is datatime. It is showed in my form as a DateTimePicker. What I want to do is that when I pick a date, all other columns show all the data of that day. Is that possible?
Well, first off - another question needs to be just that, another question in the forum.
It sounds like you're describing filtering of data and sure that's possible. When you form your new question, please be sure to show what you have (the pertinent code) and what you're trying to accomplish. A few screenshots would be helpful also.
Please call me Frank :)
Wednesday, January 9, 2013 7:06 PM -
Sorry man, I have already posted a new question!Wednesday, January 9, 2013 7:30 PM