VBA SQL select query but only show some rows -


i have table contains data trying import spreadsheet control on userform in vba/excel.

the results viewed end user, have set value of header cells on initialization opposed the column headings sql table.

my query looks this

dim conn adodb.connection dim rs adodb.recordset dim sconnstring string   sconnstring = "provider=sqloledb;data source=mysource;initial catalog=mydatabase;user id=myusername;password=mypassword;quotedid=no" set conn = new adodb.connection set rs = new adodb.recordset  conn.open sconnstring set rs = conn.execute("select * woft_tbl_clients userid =  '" & userid.value & "';") if not rs.eof    /////////////////     /something here!/     /////////////////  else   msgbox "error: no records returned.", vbcritical end if  if cbool(conn.state , adstateopen) conn.close set conn = nothing set rs = nothing 

what trying output of selected columns database , able feed them whatever colomn on spreadsheet control.

so in effect somehow loop allows me output resultset of columns id, name , userid spreadsheet control starting row 2. database contains many other columns not needed in spreadsheet, needed spreadsheet control on same userform, of appear on both.

what able have each column in own recordset, have ids stored in id recordset use in column in spreadsheet control 1, , colomn 6 in spreadsheet control 2?

i hope makes sense! using excel 2010

to have each data column 1 table in recordset lead isolated data lists, wouldn't follow logic of relational database model. if data indeed isolated in way, id list, name list , on, living in same table, - forgive me - database model quite bad.

if nevertheless want columns sql database, specify them in sql statement:

select id, name, userid tablename anycondition order name 

to loop through every record recordset object returns, use do-until loop this. don't forget movenext, or may result in endless loop.

do until rs.eof     ... want record ...      rs.movenext loop 

i hope needed. feel free further explain, if didn't understand needs correctly.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -