[thelist] Classic to Asp.NET 2.0

James Conley Conleyj at kubota-kma.com
Wed Jun 14 14:15:22 CDT 2006


> The rowspan is generated (in its current classic form):
> SELECT count(adID) as rowspan FROM marketing Where publish <= '" &
> date() & "' and expire > '" & date() & "' and preview = 0 order by
> newid()
> 
> The value I assign is simply:
> rowspan = LexJetAdsCount("rowspan").value
> 
> Then:
> <table width="766" border="0" cellspacing="2">
>   <tr valign="middle">
>     <td width="560" 
> 	<%
> 		select case rowspan
> 			case "3"
> 				response.write "rowspan=""3"""
> 			case "4"
> 				response.write "rowspan=""4"""
> 			case "5"
> 				response.write "rowspan=""5"""
> 		end select
> 		%>
> 	
> 	>
> ...
> 
> Now. What I've gotten so far in Asp.net 2.0:
> 
> Sub Page_Load(ByVal sender As Object, _
>                         ByVal e As System.EventArgs) Handles Me.Load
>          If Not Page.IsPostBack Then
>              'Start by determining the connection string value
>              Dim connString As String = _
>  
> ConfigurationManager.ConnectionStrings("Server09").ConnectionString
> 
>              'Create a SqlConnection instance
>              Using myConnection As New SqlConnection(connString)
> 
>                  'Specify the SQL query
>                  Dim sql As String = "SELECT count(adID) as 
> totals FROM lexjet_marketing_new Where publish <= '" & 
> Date.Now() & "' and expire > '" & Date.Now() & "' and preview 
> = 0 order by newid()"
>                 
>                  'Create a SqlCommand instance
>                  Dim myCommand As New SqlCommand(sql, myConnection)
> 
>                  'Get back a DataSet
>                  Dim myDataSet As New DataSet
> 
>                  'Create a SqlDataAdapter instance
>                  Dim myAdapter As New SqlDataAdapter(myCommand)
>                  myAdapter.Fill(myDataSet)

The value you seek is : myDataSet.Tables(0).Rows(0)("totals")
There are other things you may want to rework as well including getting
rid of the "response.write" stuff.
In ASP.Net there are numerous ways to generate tables. You can do this:
Dim tbl as new HTMLTable
And then add rows / cells accordingly..
Or use the GridView.


James C.



More information about the thelist mailing list