Hi there, I'm so new in ASP dev and would like to know how to show in an HTML/ASP table, data retrieved from a SQL command (DataBase). It's about a crossed-reference data. e.g.: I got this ASP code below: set rs = conn.execute("TRANSFORM Sum(dados.test) AS SumOfTest SELECT dados.spo FROM dados GROUP BY dados.spo PIVOT Format([date])") This SQL command retrieve a crossed-reference table, with labels in lines and columns and values for each line, according to the column. I want to show something like that: SPO 8/1 8/2 8/3 value1 10 15 16 value2 12 13 18 And my doubt is: How to "create" this table in HTML/ASP code, after i got the retrieve of DB? If anyone could help me, I'll appreciate!!
You CAN use a data grid view, or you might have to use the dynamic tool creation. Using tables.rows.add if i m not wrong.
You will need to iterate through the recordset and build the table using HTML tags. Something like this mytable="<TABLE>" while not rs.EOF mytable=mytable & "<TR><TD>" & rs (0) & "<\TD>" & rs(1) & "<\TD><\TR>" rs.MoveNext() wend mytable=mytable & "<\TABLE>" response.write mytable If you dont know the number of columns use a for loop to build the columns for i=0 to rs.fields.count-1 'Build columns here Next
Check this link: shahriarnk.com/Shahriar-N-K-Research-Embedding-SQL-in-C-Sharp-Java.html for details on how to connect to SQL server database from C#.NET database applications as well as Java database applications. It also describes how to pass embedded SQL queries using SQLCommand, calling stored procedures, pass parameter etc. shahriarnk.com