I am new to VB .NET and SQL Server, so I apologize if this is a basic question. I am using Visual Studio 2005 with SQL Server Express. Below is the code in question:
ChosenProjectName = TextBox2.Text
Dim NewProject As New DataSet
OpenConn()
Dim GetProjectList As String = "SELECT * FROM Approved_Projects ORDER BY Project_ID DESC"
Dim GetProjectsAdapter As SqlDataAdapter = New SqlDataAdapter(GetProjectList, MainCon)
Dim myDataSet As DataSet = New DataSet()
Dim myDataRow As DataRow
GetProjectsAdapter.Fill(myDataSet, "Approved_Projects")
Dim LastProjectID As Integer = myDataSet.Tables("Approved_Projects").Rows(0)("Pro ject_ID")
myDataRow = myDataSet.Tables("Approved_Projects").NewRow
myDataRow("Project_Name") = ChosenProjectName
myDataRow("Project_Status_ID") = 1
myDataRow("Project_Box_State_ID") = 1
myDataRow("Project_ID") = LastProjectID + 1
myDataSet.Tables("Approved_Projects").Rows.Add(myD ataRow)
Dim myDataRowsCommandBuilder As SqlCommandBuilder = New SqlCommandBuilder(GetProjectsAdapter)
GetProjectsAdapter.Update(myDataSet, "Approved_Projects")
GetProjectsAdapter.Dispose()
myDataSet.Dispose()
CloseConn()
In short, I am attempting to read data from a table of approved projects (named Approved_Projects) into a dataset, add a record, return that data through the SqlDataAdapter to my database.
Here is my question: after this piece of code runs in my program, I can reopen the connection to my database, query the data for Projects and my new record shows up fine. BUT when I go to the Server Explorer in Visual Studio to look at the new Table Data in "Approved_Projects", the new data isn't there AND when I rerun the application, the new record is absent. What am I missing here?
Any help will be greatly appreciated.
Dirk