c# 4.0 - retrieve data from access database -
i want retrieve path of image access
datatable mytable = new datatable(); oledbconnection myconnection = new oledbconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring); oledbcommand mycommand = new oledbcommand(); mycommand.commandtext = "select imagename 'imagename', imagepath 'path' [aimages] id='" + _id + "'"; mycommand.commandtype = commandtype.text; mycommand.connection = myconnection; oledbdataadapter myadapter = new oledbdataadapter(); myadapter.selectcommand = mycommand; myadapter.fill(mytable); but in last line error occurred this: data type mismatch in criteria expression.
i suspect problem way pass id, maybe can try instead:
// note id=? mycommand.commandtext = "select imagename 'imagename', imagepath 'path' [aimages] id=?"; mycommand.commandtype = commandtype.text; // parameter var pid = new oledbparameter {value = _id}; mycommand.parameters.add(pid); i hope helps.
Comments
Post a Comment