I have read many tutorials but I can't get a grasp of adding a new row to the database or even delete.
The closest example I came across is this:
I have also read this post http://www.vbdotnetforums.com/showthread.php?t=17004 which may work but they only gave an example of adding one column.
I would like the new row to be added after clicking a button. I know how to add the codes to the button but getting the row created is where i get lost. I tried changing values in the above examples but nothing happened.
Things I have created...
I am using a sql file for database (.mdf)
MyDataset
MyTableAdapter
My_Table [id, title, description, ratings] -(I should mention that "id" is autoincrement)
Could someone write an example of how I would add a new row to the database?
Thanks in advance
The closest example I came across is this:
VB.NET:
' Create a new row.
Dim newRegionRow As NorthwindDataSet.RegionRow
newRegionRow = Me.NorthwindDataSet._Region.NewRegionRow()
newRegionRow.RegionID = 5
newRegionRow.RegionDescription = "NorthWestern"
' Add the row to the Region table
Me.NorthwindDataSet._Region.Rows.Add(newRegionRow)
' Save the new row to the database
Me.RegionTableAdapter.Update(Me.NorthwindDataSet._Region)
I have also read this post http://www.vbdotnetforums.com/showthread.php?t=17004 which may work but they only gave an example of adding one column.
I would like the new row to be added after clicking a button. I know how to add the codes to the button but getting the row created is where i get lost. I tried changing values in the above examples but nothing happened.
Things I have created...
I am using a sql file for database (.mdf)
MyDataset
MyTableAdapter
My_Table [id, title, description, ratings] -(I should mention that "id" is autoincrement)
Could someone write an example of how I would add a new row to the database?
Thanks in advance