|
Posted by dakvanslam on 11/21/06 21:52
I apologize if this is a simple question, but I am very new to SQL
Server. I feel like I am missing something easy here. I an running VB
..NET from Visual Studio 2005 and SQL Server Express. The code in
question is as follows:
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)("Project_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(myDataRow)
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
Navigation:
[Reply to this message]
|