sql - Get Row number of excel using ADO -


we trying row number of particular recordset retreived based on soome condtion. consider below table

name    id abc     1 cde     2 efg     3 

now, how row number or recordset number of employee "cde" (accrding below code need result 2). on please.

const adopenstatic = 3 const adlockoptimistic = 3 const adcmdtext = &h0001 strsource="c:\test.xls" strconnection = "provider=microsoft.jet.oledb.4.0;data source=" & strsource          & ";extended properties=""excel 8.0;hdr=yes;"";"   set conn = createobject("adodb.connection")    set objrecordset = createobject("adodb.recordset") conn.open strconnection  objrecordset.open "select name [sheet1$] id = 2", conn, adopenstatic,     adlockoptimistic, adcmdtext msgbox objrecordset.getstring conn.close  set conn = nothing 

the best way put column in excel file has same data row number. query on column. full-proof solution.

however reason if can't that, try this:

const adopenstatic = 3 const adlockoptimistic = 3 const adcmdtext = &h1 dim rownumber  dim sqlstmt   strsource = "c:\temp\test.xls" strconnection = "provider=microsoft.jet.oledb.4.0;data source=" & strsource & ";extended properties=""excel 8.0;hdr=yes;"";" set conn = createobject("adodb.connection") set objrecordset = createobject("adodb.recordset") conn.open strconnection  sqlstmt = "select name, id [sheet1$]"      ''-- can optimize query if id in ascending order. e.g. "select name, id [sheet1$] id <= 4" objrecordset.open sqlstmt, conn, adopenstatic, adlockoptimistic, adcmdtext objrecordset.find "id = 4" rownumber = objrecordset!id + 1  ''-- +1 header row. conn.close set conn = nothing  msgbox rownumber 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -