T
T.K Kullervo
Hi,
Im sorry, but i have never really used a database from VB. Im showing data
from a
database via a datagrid and i want the user to be able to update the records
by writing on the datagrid. Could someone help me with this code
Dim cn2 As OleDbConnection
Dim strSelect2 As String
Dim dscmd2 As OleDbDataAdapter
Dim ds2 As New DataSet
Dim dt2 As DataTable
Dim strConnection As String
Public Sub openDb()
Dim key As Microsoft.Win32.RegistryKey
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("EN_DIN_ASME")
Dim path As String = CType(key.GetValue("pathTo"), String)
Dim strConnection As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& path
cn2 = New OleDbConnection(strConnection)
cn2.Open()
End Sub
Public Sub GetData()
strSelect2 = "SELECT..."
dscmd2 = New OleDbDataAdapter(strSelect2, cn2)
dscmd2.Fill(ds2, "ENDIMASME")
dt2 = ds2.Tables.Item("ENDIMASME")
syottogrid.DataSource = ds2
syottogrid.DataMember = "ENDIMASME"
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
dscmd2.Update(dt2)
End Sub
When i click the update button it says:
Update requires a valid UpdateCommand when passed DataRow collection with
modified rows.
Help me.....
Im sorry, but i have never really used a database from VB. Im showing data
from a
database via a datagrid and i want the user to be able to update the records
by writing on the datagrid. Could someone help me with this code
Dim cn2 As OleDbConnection
Dim strSelect2 As String
Dim dscmd2 As OleDbDataAdapter
Dim ds2 As New DataSet
Dim dt2 As DataTable
Dim strConnection As String
Public Sub openDb()
Dim key As Microsoft.Win32.RegistryKey
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("EN_DIN_ASME")
Dim path As String = CType(key.GetValue("pathTo"), String)
Dim strConnection As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& path
cn2 = New OleDbConnection(strConnection)
cn2.Open()
End Sub
Public Sub GetData()
strSelect2 = "SELECT..."
dscmd2 = New OleDbDataAdapter(strSelect2, cn2)
dscmd2.Fill(ds2, "ENDIMASME")
dt2 = ds2.Tables.Item("ENDIMASME")
syottogrid.DataSource = ds2
syottogrid.DataMember = "ENDIMASME"
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
dscmd2.Update(dt2)
End Sub
When i click the update button it says:
Update requires a valid UpdateCommand when passed DataRow collection with
modified rows.
Help me.....