c# - "A quotation mark delimiter is missing from the end of the query." error in WinCE PDA application -
in wince pda application, doing comparing barcode value scanned 1 in database generate table.
i build query this:
for (int = 0; < listbox2.items.count; i++) { if (i == 0) { sb.append("select * toolsbar barcodevalue in ("); } sb.append("'" + listbox2.items[i] + "',"); } sb.length = sb.length - 1; sb.append(")");
and use here:
cmd.commandtext = sb.tostring(); cmd.commandtype = commandtype.text; cmd.connection = con; con.open(); reader = cmd.executereader(); // error came out "a quotation mark delimiter missing end of query." reader.close(); sqlcedataadapter ad = new sqlcedataadapter(sb.tostring(), con); dataset ds = new dataset(); ad.fill(ds); datagrid2.datasource = ds.tables[0]; con.close(); sb.length = 0;
alternate loop build query removes need alter string length:
for (int = 0; < listbox2.items.count; i++) { if (i == 0) { sb.append("select * toolsbar barcodevalue in ("); sb.append("'" + listbox2.items[i] + "'"); } else { sb.append(",'" + listbox2.items[i] + "'"); } } sb.append(")");
Comments
Post a Comment