Run-time Error 91: object variable or with block variable not set while linking VB6 and MS access -
when run given original code error in below line shown "run-time error 91"
con.open "provider=microsoft.jet.4.0;data source=c:\documents , settings\xpmuser\desktop\new folder\prac1.mdb; persist security info = false"
original code
dim con adodb.connection dim rs adodb.recordset private sub submit_click() con.open "provider=microsoft.jet.4.0;data source=c:\documents , settings\xpmuser\desktop\new folder\prac1.mdb; persist security info = false" rs.open "select dbtb1 prac1", con, adopendynamic, adlockpessimistic rs.fields("number").value = text1.text rs.fields("name").value = text2.text rs.fields("city").value = text3.text msgbox "data saved!", vbinformation rs.update end sub
you getting error 91 because have not created connection object. further, same error recordset. have updated code allow work:
private sub submit_click() set con = new adodb.connection con.open "provider=microsoft.jet.4.0;data source=c:\documents , settings\xpmuser\desktop\new folder\prac1.mdb; persist security info = false" set rs = new adodb.recordset rs.open "select dbtb1 prac1", con, adopendynamic, adlockpessimistic rs.addnew rs.fields("number").value = text1.text rs.fields("name").value = text2.text rs.fields("city").value = text3.text rs.update msgbox "data saved!", vbinformation end sub
also, please note addition of addnew
prior updating database.
Comments
Post a Comment