|
-
Feb 25th, 2008, 01:57 AM
#1
Thread Starter
New Member
Error in updating access db. using vb6.....
Hi All..
I am accessing 2 colums from access database and updating them .
Option Explicit
Dim c As New adodb.Connection
Dim cn As New adodb.Connection
Dim cm As adodb.Command
Dim rsnew2 As New adodb.Recordset
Private Sub cmd_edit_Click()
If text1.Text = "" Then
MsgBox " enter the company name"
text1.SetFocus
rsnew2.Fields("text1") = text1.Text
End If
If text2.Text = "" Then
MsgBox " enter the company address"
text2.SetFocus
rsnew2.Fields("text2") = text2.Text
End If
rsnew2.Update
MsgBox " add new successful ", vbInformation, "successful"
End Sub
Private Sub Form_Load()
Dim cs As String
c.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\COMION.MDB;Persist Security Info=False")
rsnew2.Open "select * from company", c, adOpenDynamic
Me.text1.Text = rsnew2(2)
Me.text2.Text = rsnew2(3)
End Sub
There is error in RSNEW2.UPDATE ..
CAN ANYBODY HELP ME TO SOLVE MY PROBLEM ??????????
-
Feb 25th, 2008, 02:35 AM
#2
Re: Error in updating access db. using vb6.....
-
Feb 25th, 2008, 02:44 AM
#3
Thread Starter
New Member
Re: Error in updating access db. using vb6.....
run time error:::3251
Current recordset does not support updation..This may be a limitation of the provider or of the selected locktype
-
Feb 25th, 2008, 02:49 AM
#4
Re: Error in updating access db. using vb6.....
You need to add the lock type when you open the recordset, like adLockOptimistic.
vb Code:
rsnew2.Open "select * from company", c, adOpenDynamic, adLockOptimistic
It defaults to a read only lock type if you don't
-
Feb 25th, 2008, 02:54 AM
#5
Thread Starter
New Member
Re: Error in updating access db. using vb6.....
Still there is an error..
error is Run time error::3705
Operation is not allowed when object is open...
-
Feb 25th, 2008, 02:56 AM
#6
Re: Error in updating access db. using vb6.....
-
Feb 25th, 2008, 03:00 AM
#7
Thread Starter
New Member
Re: Error in updating access db. using vb6.....
 Originally Posted by wes4dbt
what line?
error in this line...
rsnew2.Open "select * from company", c, adOpenDynamic, adLockOptimistic
I tried by changing renew2 to new recordset i.e (rsnew3) .. I am getting message that "edit is successful", but its not updating in database..
-
Feb 25th, 2008, 03:10 AM
#8
Re: Error in updating access db. using vb6.....
This means that you have already opened the recordset sometime before. I don't see any code where you close the recordset. You should always close the recordset after you use it. You can check if its open like this
Code:
if rsnew2.State = adStateOpen then
' it is already open
else
' open rs
end if
-
Feb 25th, 2008, 03:23 AM
#9
Thread Starter
New Member
Re: Error in updating access db. using vb6.....
 Originally Posted by wes4dbt
This means that you have already opened the recordset sometime before. I don't see any code where you close the recordset. You should always close the recordset after you use it. You can check if its open like this
Code:
if rsnew2.State = adStateOpen then
' it is already open
else
' open rs
end if
rsnew2 or rsnew3????
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
|