[thelist] Classic to Asp.NET 2.0

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Wed Jun 14 14:41:28 CDT 2006



				> 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. 

   Also, forego the DataGrid and DataSet.Fill operations; these are needless overhead.  Just use SqlCommand.ExecuteScalar to return the one value that you need.

   And seriously, download Reflector; it's the most-used tool in my (admittedly small) arsenal.

Peter

				From: "James Conley" Conleyj at kubota-kma.com

> 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:
> 

> 

> 

> <%
> 		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.
-- 

* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 





More information about the thelist mailing list