|
-
Oct 15th, 2009, 01:11 AM
#1
Thread Starter
Lively Member
Finding the valid update command
This is for visual basic 2008 express edition.Ive been trying to update records from the table of my memrec.dbml and dbase1DataSet.xsd in the visual basic environment.Im not using any sql database server but Im just using the built-in sql server within the visual basic 2008 express.I was able to add records and retreived it to display in the textboxes.My 1st block of codes I used to edit records has an error message which says:
NotSupportedException was unhandled - Sql server does not handle comparison of NText, Text, Xml, or Image data types.
My 2nd block of codes I tried to used doesn't have any error and it ables to change the records while at runtime but when you exit the program the changes was not save at all cause when you run it again the records that were changed during runtime goes back to its original records.
Let me take you a look at the two blocks of codes
******************1st block of codes***********************
Private Sub Button5_Click(------------------) Handles Button5.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
MsgBox("Please Fill It Up Completely",MsgBoxStyle.Exclamation)
Exit Sub
Else
Dim accnt As String
accnt = TextBox1.Text
Dim db As New memrecDataContext()
Dim editrecord = _
From memrec In db.Table1s _
Where memrec.Account.Contains(accnt) _
Select memrec
For Each memrec In editrecord
If memrec.Account = accnt Then
memrec.Account = TextBox1.Text
memrec.Name = TextBox2.Text
memrec.Address = TextBox3.Text
memrec.Gender = TextBox4.Text
db.SubmitChanges()
Exit Sub
End If
Exit For
Next
MsgBox("No Records Match",MsgBoxStyle.Information)
End If
End Sub
********************************************************
*****************2nd block of codes*************************
Private Sub Button5_Click(------------------) Handles Button5.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
MsgBox("Please Fill It Up Completely",MsgBoxStyle.Exclamation)
Exit Sub
Else
Dim accnt As String
accnt = TextBox1.Text
Dim editrecord = _
From memrec In Form6.dbase1DataSet.Table1 _ 'instead of db.Table1s
Where memrec.Account.Contains(accnt) _
Select memrec
For Each memrec In editrecord
If memrec.Account = accnt Then
memrec.Account = TextBox1.Text
memrec.Name = TextBox2.Text
memrec.Address = TextBox3.Text
memrec.Gender = TextBox4.Text
Exit Sub
End If
Exit For
Next
MsgBox("No Records Match",MsgBoxStyle.Information)
End If
End Sub
*****************************************************
For the 2nd block of codes,i tried to add update command to save the changes after you exit the program and the 1st code I added was Form6.dbase1DataSet.SubmitChanges() but visual basic 2008 express wont give you an option to select SubmitChanges().The 2nd code I tried to add was Form6.Table1TableAdapter.Update(Form6.dbase1DataSet.Table1) but it still leaves an error message says:InvalidOperationException was unhandled-Update requires a valid update command when passed datarow collection with modified rows.
Questions:
1.What do you see as possible cause for having an error in 1st block of codes?What's the remedy for that?
2.For the 2nd block of codes,what is the valid update command to be added in the line in order to save the changes not just during runtime but until you exit the program and run it again?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|