SqlConnection cnn = new SqlConnection("Server=.;Initial Catalog = AdventureWorksDW;Integrated Security =True"); string qry = "SELECT top 100 [fldname1],[fldname2],[fldname3],[fldname4],[fldname5],[fldname6] FROM [Customer]"; SqlCommand cmd = new SqlCommand(qry, cnn); cmd.Connection.Open(); SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); string strTable = "<table class='datatable'>"; strTable += "<thead>"; strTable += "<tr><th id='customerkey'>CustomerKey</th><th ><a href='javascript:display(this,\"firstname\")'>FirstName</a></th><th id='lastname'>Lastname</th><th id='BirthDate'>DOB</th><th id='MaritalStatus'>Marital Status</th><th id='EmailAddress'>Email</th></tr>"; strTable += "</thead>"; strTable += "<tbody>"; while (myReader.Read()) { strTable += "<tr><td>" + myReader[0].ToString() + "</td><td>" + myReader[1].ToString() + "</td><td>" + myReader[2].ToString() + "</td><td>" + myReader[3].ToString() + "</td><td>" + myReader[4].ToString() + "</td><td>" + myReader[5].ToString() + "</td></tr>"; } myReader.Close(); strTable += "</tbody></table>"; Response.Write(strTable);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)