vb.net - Converting a OleDbDataReader to a String to display a COUNT command in List View -
i want display in listview
count
of specific employee name whilst using 2 ms access
queries. count
being displayed 0, 1 or 2 there many none "----" values in database.
the command binded radiobutton
:
private sub radiobutton2_click(sender object, e eventargs) handles radiobutton2.click dim con new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=" & application.startuppath & "\sheetlog.mdb;jet oledb:database password = 'password';") con.open() dim try2 string = "----" dim try3 string dim oledbcmd, oledbcmd2 oledbcommand dim cmd, cmd2 string cmd = "select distinct empname sheet" oledbcmd = new oledbcommand(cmd, con) dim oledbreader oledbdatareader = oledbcmd.executereader() listview1.clear() listview1.gridlines = true listview1.fullrowselect = true listview1.view = view.details listview1.multiselect = false listview1.columns.add("employee name", 130) listview1.columns.add("new", 80) listview1.columns.add("rev1", 80) listview1.columns.add("rev2", 80) listview1.columns.add("rev3", 80) listview1.columns.add("rev4", 80) listview1.columns.add("rev5", 80) while (oledbreader.read) try3 = oledbreader("empname").tostring cmd2 = "select count(new) cnew, count(rev1) crev1, count(rev2) crev2, count(rev3) crev3, count(rev4) crev4, count(rev5) crev5 sheet empname = '" & try3 & "' , rev1 <> '" & try2 & "' , rev2 <> '" & try2 & "' , rev3 <> '" & try2 & "' , rev4 <> '" & try2 & "' , rev5 <> '" & try2 & "'" oledbcmd2 = new oledbcommand(cmd2, con) dim oledbreader2 oledbdatareader = oledbcmd2.executereader() while (oledbreader2.read) listview1.items.add(oledbreader("empname")) .subitems.add(oledbreader2("cnew")) .subitems.add(oledbreader2("crev1")) .subitems.add(oledbreader2("crev2")) .subitems.add(oledbreader2("crev3")) .subitems.add(oledbreader2("crev4")) .subitems.add(oledbreader2("crev5")) end end while end while con.close() end sub
i've been away vb.net bit, think need while(oledbreader2.read())
for second datareader:
dim oledbreader2 oledbdatareader = oledbcmd2.executereader() ' think need here: while (oledbreader2.read) listview1.items.add(oledbreader("empname")) .subitems.add(oledbreader2("cnew")) .subitems.add(oledbreader2("crev1")) .subitems.add(oledbreader2("crev2")) .subitems.add(oledbreader2("crev3")) .subitems.add(oledbreader2("crev4")) .subitems.add(oledbreader2("crev5")) end end while
Comments
Post a Comment