Click to See Complete Forum and Search --> : update problem


sanjeev111
February 14th, 2009, 05:55 AM
I am using following code to update Access 2000 table. It executes the query but database is not updated and no error is generated. any body can help?


Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim varGroupId As Integer
Dim str As String
cn1 = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App_Path() & "\client.mdb;")
cn1.Open()
varGroupId = dgvGroup("clmGroupId", dgvGroup.CurrentRow.Index).Value
str = "Update GroupMaster set [GroupName]='" & txtGroupName.Text & "' WHERE [GroupID]=" & varGroupId
cmd1 = New OleDbCommand(str, cn1)
dr1 = cmd1.ExecuteNonQuery()
MsgBox(dr1)
cn1.Close()
cmd1.Dispose()
End Sub

dglienna
February 14th, 2009, 01:54 PM
Does it execute in Access?

http://www.java2s.com/Code/VB/Database-ADO.net/UpdateAccessdatatablethroughOleDbConnection.htm

sanjeev111
February 15th, 2009, 04:03 AM
Yes, This query is working in Access 2000.

dglienna
February 15th, 2009, 08:37 PM
Paste it here, The query that WORKS in Access (with all values)

sanjeev111
February 16th, 2009, 06:24 AM
Query that worked in Access 2000 is

UPDATE GroupMaster SET GroupName = 'san' WHERE GroupID=2;

Table structure is:

GroupID Number
GroupName Text Required Yes AllowZeroLength No
Remark Memo
ParentGroupID Number

DataMiser
February 17th, 2009, 03:06 AM
Could it be the log in info? I don't user a user or password... perhaps getting read only access?