populate values in textbox if select combobox vb6 -
i using vb 6.0 have 1 form (form1), 1 combobox (combobox1), , 1 textbox (textbox1)i have 1 table (salary) in local database created within project.in table 'salary' have 4 columns (userid - primary key, salary type, salary range)the table has multiple records in it.
what need find out how have textbox populate corresponding columns whatever selected in combobox. , appreciated.
here code used link database vb :
private withevents cmdpopulate commandbutton private withevents dcbdatacombo datacombo private sub form_load() dim rs adodb.recordset dim strconnect string dim strsql string strconnect = "provider=microsoft.ace.oledb.12.0;data source=c:\users\mahmoud\desktop\project\database.mdb;persist security info=false" strsql = "select distinct * salary order userid asc" ' set ascending order set rs = new adodb.recordset rs .cursortype = adopenstatic .locktype = adlockreadonly .open source:=strsql, _ activeconnection:=strconnect, _ options:=adcmdtext end set datacombo1.rowsource = rs datacombo1.listfield = "userid" datacombo1.datafield = "userid" end sub
you wrote:
activeconnection:=strconnect
but strconnect string, while activeconnection require adodb.connection object, not string. moreover, connection must open:
dim cn adodb.connection set cn = new adodb.connection cn.connectionstring = strconnect cn.open cn.cursorlocation = aduseclient ' recordset: rs.open strsql, cn, adopenstatic, adlockreadonly, adcmdtext
Comments
Post a Comment