SolveErrors
Visual Basic

cannot update database (dataset is updating)

33 views

On a form i have several text boxes binded to a bindingsource and including a datagridview
I have populated the textboxes with database fields successfully and the datagridview displays the correct information.
I have the following code to save the information to the database but i cannot get it to work.

Private Sub SaveRecordData()
??????????????????????????????
dS.Tables("Recipe".Rows(RecipeBindingSource.Position).Item("Title") = txtTitle.Text
???????????
dS.Tables("Recipe").Rows(RecipeBindingSource.Position).Item("Notes") = txtNotes.Rtf
???????
adapter.Update(dS, "Recipe")
end sub

i have made the ds (dataset) and adapter global variables and were used when i filled the database

Sub FillDatabase()
ConnectionString = gINI(iniFile, "Settings", "ConnectionString", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\RECIPE.MDB")
Me.RecipeTableAdapter.Fill(Me.recipedataset1.Recipe)
?????? Dim sQuery As String = ""
?????? Try
?????? If RN = 0 Then
?????????? sQuery = "SELECT * FROM [RECIPE] ORDER BY [TITLE], [CATEGORY]"
?????? Else
?????????? sQuery = "SELECT * FROM [RECIPE] WHERE [USERID]=" & RN & " ORDER BY [TITLE], [CATEGORY]"
?????? End If

?????? Dim adapter As New OleDb.OleDbDataAdapter(sQuery, Connection)
?????? dS = New DataSet()
?????? dS.Tables.Add("Recipes")
?????? adapter.Fill(dS, "Recipe")
?????? Me.RecipeBindingSource.DataMember = "Recipe"
?????? Me.RecipeBindingSource.DataSource = dS
?????? Connection.Close()
?????? BindData() e.g. txtTitle.DataBindings.Add(New System.Windows.Forms.Binding("Text", RecipeBindingSource, "Title", True))
????? End Sub

I have tried many code examples here in order to save the data, none of which has worked.
Can anyone please help me with this?

More Visual Basic fixes

how to Add asp.net web pages (vb.net code behind) to sharepoint siteCannot unload a Form Using Proper CodeRe: On screen KeyboardWORD -> DATE, WORD -> TIME (C->VB)Re: Help Please - Insert from txt >> Module or somethinghow to add node to treeview at runtime in vb6.0 ?