dukeofawesome
Member
Hi,
After about 2 days of working on using a Data Class to return values from a database I'm finally getting somewhere. I can return data and read data without issue. What I'm having a major issue with is editing and writing data back to the database. My class looks like so:
I tried to add the following, but can't make it work:
I'm assuming there is a better way of doing this, but this is what I've managed to put together so far so hopefully someone can point me to a good tutorial becuase this sort of stuff is very hard to find on Google. Any guidance will be most appreciated.
Thanks
After about 2 days of working on using a Data Class to return values from a database I'm finally getting somewhere. I can return data and read data without issue. What I'm having a major issue with is editing and writing data back to the database. My class looks like so:
VB.NET:
Imports System.Data.OleDb
Public Class clsDatabase
Dim cnn As New OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim da As OleDb.OleDbDataAdapter
Dim ds As New DataSet
Sub ConnectDB()
dbProvider = My.Settings.DatabaseCon
cnn.ConnectionString = dbProvider
cnn.Open()
End Sub
Sub CloseDB()
cnn.Close()
End Sub
Function sqlSelect(ByVal strSQL As String)
da = New OleDbDataAdapter(strSQL, cnn)
da.Fill(ds, "Results")
Return ds
End Function
End Class
I tried to add the following, but can't make it work:
VB.NET:
Sub AddNew()
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.Update(ds, "Results")
End Sub
I'm assuming there is a better way of doing this, but this is what I've managed to put together so far so hopefully someone can point me to a good tutorial becuase this sort of stuff is very hard to find on Google. Any guidance will be most appreciated.
Thanks