Hello,
Please forgive me if this is a really obvious question.
I am just starting to explore Visual Studio 2005 and am
having a problem
saving records to a database. I have created a very simple
project using
1 form and I set up a database using the create new
datasource wizard. I
created 1 table (by right clicking on the tables folder in
the server
explorer window)
I then simply dragged the table from the Data Sources window
onto my
form where it created a grid for me along with a navigator,
table
adaptor, etc.
Here is the total code:
Public Class Form1
Private Sub NameBindingNavigatorSaveItem_Click(ByVal
sender As
System.Object, ByVal e As System.EventArgs) Handles
NameBindingNavigatorSaveItem.Click
Try
Me.Validate()
Me.NameBindingSource.EndEdit()
Me.NameTableAdapter.Update(Me.TestDatabaseDataSet.name)
MsgBox("Saved successfully")
Catch ex As Exception
MsgBox("Problem saving")
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'TestDatabaseDataSet.name' table. You can move, or remove
it, as needed.
Me.NameTableAdapter.Fill(Me.TestDatabaseDataSet.name)
End Sub
End Class
When I run the project, I can enter data in the fields, I
click the save
button and get the msg that the save is successful.
However, if I close
the application and the restart it, the data is not
displayed. I checked
using the "show table data" menu when I right
click the table in the
server explorer window and it also shows no data.
Can someone point out what I am not doing correctly?
Thanks,
Michael K.
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|