sql - Getting Data MS Access then Placing it inside VBNET texbox -


i'm trying figure out what's wrong code, i'm trying extract value of employe id selected dropdown, information of employee , place in textbox vb.net form, there's error whenever select employee id it's giving me error message of : "an unhandled exception of type 'system.data.oledb.oledbexception' occurred in system.data.dll

additional information: no value given 1 or more required parameters."

thus highlighting reader, i'm not sure what's problem, have initialized reader... please guide me. thanks

private sub enumtext_selectedindexchanged(sender object, e eventargs) handles enumtext.selectedindexchanged           dim dbsource = "data source= c:\databse\company_db.accdb"         con.connectionstring = "provider=microsoft.ace.oledb.12.0; data source= c:\databse\company_db.accdb"          dim sqlquery string         dim sqlcommand new oledbcommand         dim sqladapter new oledbdataadapter         dim table new datatable          dim empnum string         dim empfname string         dim emplname string         dim empdept string         dim empstat string         dim empyears string          empnum = enumtext.text         empfname = empfnametext.text         emplname = emplnametext.text         empdept = depttext.text         empstat = stattext.text         empyears = yearstext.text          sqlquery = "select * tbl_empinfo empid empnum"          sqlcommand             .commandtext = sqlquery             .connection = con             .parameters.addwithvalue("empid", empnum)             sqladapter                 .selectcommand = sqlcommand                 .fill(table)             end             datagridview1                 .datasource = table             end         end          dim path = "data source= c:\databse\company_db.accdb"         dim command = "select * tbl_empinfo empid empnum"         querydata(path, command)           con.close()      end sub     private sub querydata(pathdb string, command string)         pathdb = "data source= c:\databse\company_db.accdb"         using connection new system.data.oledb.oledbconnection("provider=microsoft.ace.oledb.12.0;data source=" & pathdb)             using da new system.data.oledb.oledbcommand(command, con)                 con.open()                  dim reader = da.executereader()                 if reader.read()                     empfnametext.text = reader("firstname")                     emplnametext.text = reader("lastname")                 end if                  con.close()             end using         end using     end sub 

you need prefix parameter empnum @: @empnum. see answer: how pass parameter vb.net example.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -