Get Datareader
Skip Navigation Links.

Get Datareader

Skip Navigation LinksHome :: ASP.NET :: Parameterized Query Class :: Fill a Datareader

here's the actual code (being called) for this page...

Dim pq As New ParameterizedQuery.ParameterizedQuery("Suppliers")

'only get suppliers where the CompanyID field = 1 (using IntegerEquals)

pq.AddParameter("CompanyID", 1, ParameterizedQuery.ParamType.IntegerEquals)

pq.OrderBy = "CompanyName"

'here's the magic bit - pass the SQL command from the ParameterizedQuery into a SqlDataAdapter

Dim adapter As New SqlClient.SqlDataAdapter(pq.SQLCommand)

Dim ds As New DataSet 'fill a dataset - you should be familiar with the rest of the .Net code below

adapter.Fill(ds, "myTable")

'run through the table and write one of the fields onto the page (in a table)

If ds.Tables(0).Rows.Count > 0 Then

Response.Write("<table class='pricing' border='1'>")

For Each row As DataRow In ds.Tables(0).Rows

Response.Write("<tr><td>" & row("CompanyName") & "</td></tr>")

Next

Response.Write("</table>")

End If

pq.Dispose() 'cleanup


The results

::
10 Bar
Agfa
Amphibico
Aquatica
Aquavideo
Bonica
Canon
Casio
Epoque
Equinox
Fantasea
Fuji
Gates
GB
HP
Hugyphot
Ikelite
Konica
Light & Motion
Minolta
Miscellaneous Suppliers
Nauticam
Nexus
Nikon
Nimar
Olympus
Panasonic
Pelican
Pentax
Sea & Sea
Seacam
Sealife
Sealux
Seatool
Sony
Subal
Top Dawg
UK
Underwater Kinetics
Underwater Research Products
UnderwaterPhotography.com
UR pro

Full Documentation here

You may reuse this code BUT not for sale AND ONLY with credit to www.BennySutton.com

Next >> AJAX
top of page
all content ©1996/2012 BennySutton.com
all images © their respective owners This site uses Thumbshots previews