Cannot edit the existing record
-
:(Hi Everybody! I am using VB6.0 & SQL Server 7.0 Following is my database Connection code Dim db As ADODB.Connection Dim rs As ADODB.Recordset Dim sql As String Set db = New ADODB.Connection db.Provider = "SQLOLEDB" db.ConnectionString = "server=SUNANDA;uid=sa;pwd=ranjita1;database=crm" db.Open Set rs = New ADODB.Recordset sql = "Select * from AccountHead" Set rs.ActiveConnection = db rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open sql, , , , adCmdText I have placed buttons on the form to Add, Delete, Edit and Update the records of the table. But in the click event of the Update button, the recordset is not supporting the Edit method. The only method it is showing in (VBA) the dropdown list is EditMode. How will I then Edit the records? Pls. help me out. Thankyou.
-
:(Hi Everybody! I am using VB6.0 & SQL Server 7.0 Following is my database Connection code Dim db As ADODB.Connection Dim rs As ADODB.Recordset Dim sql As String Set db = New ADODB.Connection db.Provider = "SQLOLEDB" db.ConnectionString = "server=SUNANDA;uid=sa;pwd=ranjita1;database=crm" db.Open Set rs = New ADODB.Recordset sql = "Select * from AccountHead" Set rs.ActiveConnection = db rs.CursorLocation = adUseClient rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open sql, , , , adCmdText I have placed buttons on the form to Add, Delete, Edit and Update the records of the table. But in the click event of the Update button, the recordset is not supporting the Edit method. The only method it is showing in (VBA) the dropdown list is EditMode. How will I then Edit the records? Pls. help me out. Thankyou.
Hi Dear please concentrate on your following code rs.CursorType = adOpenStatic As you had open the cursor in Static mode there is no edit permission for this record set. You gave to open the recordset in non static mode. Regards
Tushar kothari
-
Hi Dear please concentrate on your following code rs.CursorType = adOpenStatic As you had open the cursor in Static mode there is no edit permission for this record set. You gave to open the recordset in non static mode. Regards
Tushar kothari
Hi! Tushar I have tried with rs.CursorType=adOpenDynamic But of no use. Pls. suggest. regards ranjita
-
Hi! Tushar I have tried with rs.CursorType=adOpenDynamic But of no use. Pls. suggest. regards ranjita
Hi If you want just to update the record in recordset then you have to set the fileds values of rs then call rs.update If this method is not wirking the please relpy back then I will try some odd solution for you. Regards
Tushar kothari
-
Hi If you want just to update the record in recordset then you have to set the fileds values of rs then call rs.update If this method is not wirking the please relpy back then I will try some odd solution for you. Regards
Tushar kothari
I wants to edit the existing record and then update. what u r suggesting that i am using in the click event of my save button. regards ranjita
-
I wants to edit the existing record and then update. what u r suggesting that i am using in the click event of my save button. regards ranjita
Hi This is the tested code so please use it Private Sub Form_Load() Dim db As ADODB.Connection Dim rs As ADODB.Recordset Dim sql As String Set db = New ADODB.Connection db.Provider = "SQLOLEDB" db.ConnectionString = "Provider=SQLOLEDB.1;Password=thk;Persist Security Info=True;User ID=thk;Initial Catalog=Dhanavantari;Data Source=TUSHAR" db.Open Set rs = New ADODB.Recordset sql = "Select * from WardMaster" Set rs.ActiveConnection = db rs.CursorLocation = adUseServer rs.CursorType = adOpenDynamic rs.LockType = adLockPessimistic rs.Open sql, , , , adCmdText End Sub on Save client button rs.Fields(1) = trim(txtwardname.text) rs.Fields(2) = val(txtrate.text) rs.Update So now you can edit the recordset and then update it ADO is the connected type of recordset so you can update one record at a time. If you have some other problem which i had not understand the please brief it regards :)
Tushar kothari