Add New compliling, but not actually adding record
I have a add new, which adds a record to a dataset that I have got to compile, but it is not updating the database at all. After using an addnew upon a table do you have to assign the table to the database again?
Full Code:-
If DialogResult.Yes = MessageBox.Show("You are about to update the database", "Confirm Update", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) Then
Dim DataScroll As New DataSet
Dim QScroll As String
QScroll = "select Message from scrollingmsg"
myadapter = New OleDb.OleDbDataAdapter(QScroll, myConnection)
myadapter.Fill(DataScroll, "scrollingmsg")
Dim TblScroll As DataTable = New DataTable
TblScroll = DataScroll.Tables("scrollingmsg")
Dim SurveyRow As DataRow
SurveyRow = TblScroll.NewRow()
If DataScroll.Tables("scrollingmsg").Rows.Count - 1 > 0 Then
SurveyRow = TblScroll.Rows(0)
SurveyRow.BeginEdit()
'what you are updating too
SurveyRow("Message") = TxtScroll.Text
SurveyRow.EndEdit()
'Updates Database
Dim objcommandbuilder As New OleDb.OleDbCommandBuilder(myadapterJobNo)
myadapter.Update(DataScroll, "scrollingmsg")
Else
'Create New Row
'SurveyRow("Message") = TblScroll.NewRow()
'what you are updating too
SurveyRow("Message") = TxtScroll.Text
''''Not working !!!!!!
TblScroll.Rows.Add(SurveyRow)
End If
myadapter.Dispose()
End If
I know I am doing something stupid, but not sure what
Thanks in advance
Louisa
|