c# - Combine query and use 1 datareader -
i want receive 2 values datareader. don't know how put 1 query. , how can receive using 1 sqldatareader?
string query = "select date ars.kmstand ritnr=(select max(ritnr) ars.kmstand)"; string query2 = "select nr ars.kmstand ritnr=(select max(ritnr) ars.kmstand)"; sqlcommand com = new sqlcommand(query2, conn); sqldatareader rt = com.executereader(); while (rt.read()) { ritnr = rt.getint32(0); } rt.close(); sqlcommand comm = new sqlcommand(query, conn); sqldatareader rd = comm.executereader(); while (rd.read()) { value = rd.getsqldatetime(0); }
combine queries , pass column index getxxx methods of idatareader value of each column result set.
string query = "select nhr, date ars.kmstand ritnr=(select max(ritnr) ars.kmstand)"; sqlcommand com = new sqlcommand(query, conn); sqldatareader rt = com.executereader(); while (rt.read()) { int nhr = rt.getint32(0); sqldatetime date = rt.getsqldatetime(1); } rt.close();
Comments
Post a Comment