ms access - How to update recordset? How to pass data value from a datagrid to textbox and edit in VB6? -


i using vb6 in system. want pass selected row value of datagrid textbox , edit record. i'm getting error every time run code. "either bof or eof true, or current record has been deleted. requested operation requires current record." here's codes in update button. please help. in advance! :d

private sub cmdedit_click() dim conn new connection dim myrs new recordset dim sql integer  conn.open "provider=microsoft.jet.oledb.4.0;datasource=c:\users\fscndcit\desktop\gstd\gstddb.mdb" myrs.cursorlocation = aduseclient myrs.open "select * table1 id = '" & datagrid1.text & "'", conn, adopendynamic, adlockbatchoptimistic  frmgosee.txtid.text = myrs!id  'this line highlighted. frmgosee.txtgstd.text = myrs!gstdcode frmgosee.txtgstdcode.text = myrs!workgroup frmgosee.txttl.text = myrs!tl frmgosee.txtdepthead.text = myrs!depthead frmgosee.txtparticipants.text = myrs!participants frmgosee.txtcoach.text = myrs!coach frmgosee.txtproblem_des.text = myrs!problem_des frmgosee.txtmi.text = myrs!mi frmgosee.txtinter_correction.text = myrs!inter_correction frmgosee.txticwho.text = myrs!icwho frmgosee.txticwhen.text = myrs!icwhen frmgosee.txticstatus.text = myrs!icstatus frmgosee.lblpicture.caption = myrs!picture frmgosee.image1.picture = loadpicture(lblpicture)  myrs.update set myrs = nothing conn.close  end sub 

the error telling query did not bring records. code assumes there record. should check empty recordset before trying assign values.

private sub cmdedit_click()     dim conn new connection     dim myrs new recordset     dim sql integer      conn.open "provider=microsoft.jet.oledb.4.0;datasource=c:\users\fscndcit\desktop\gstd\gstddb.mdb"     myrs.cursorlocation = aduseclient     myrs.open "select * table1 id = '" & datagrid1.text & "'", conn, adopendynamic, adlockbatchoptimistic      if myrs.eof = false         frmgosee.txtid.text = myrs!id  'this line highlighted.         frmgosee.txtgstd.text = myrs!gstdcode         frmgosee.txtgstdcode.text = myrs!workgroup         frmgosee.txttl.text = myrs!tl         frmgosee.txtdepthead.text = myrs!depthead         frmgosee.txtparticipants.text = myrs!participants         frmgosee.txtcoach.text = myrs!coach         frmgosee.txtproblem_des.text = myrs!problem_des         frmgosee.txtmi.text = myrs!mi         frmgosee.txtinter_correction.text = myrs!inter_correction         frmgosee.txticwho.text = myrs!icwho         frmgosee.txticwhen.text = myrs!icwhen         frmgosee.txticstatus.text = myrs!icstatus         frmgosee.lblpicture.caption = myrs!picture         frmgosee.image1.picture = loadpicture(lblpicture)          'commented because nothing in record has changed         'there nothing update         'myrs.update     end if      'checking state of objects here before closing practice     if not myrs nothing         if myrs.state = adstateopen             myrs.close         end if         set myrs = nothing     end if     if not conn nothing         if conn.state = adstateopen             conn.close         end if         set conn = nothing     end if  end sub 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -