Tuesday, March 20, 2012

asp > asp.net

I'm in the process of trying to learn asp.net and one of the things I'd like to tackle right off the bat is a simple display from my SQL server. Below is some of my "classic" asp that works fine. I suppose what I want to know is, what would this code look like in .net?

<%

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("inet_dvdauthority")
sql = "SELECT * FROM contest_text where dte = '3/14/2004' order by id"

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open sql, Conn, adOpenStatic, adLockReadOnly, adCmdText

%
<p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td class="reviewheader" colspan="2">dvd/authority contest - week of <%=RS("dte")%><br><br></td>
</tr>
<%
If RS.EOF Then
%>
<tr>
<td>No Contest found.</td>
</tr>
<%
Else
%>
<%
Do Until RS.EOF
%>
<tr>
<td width="110" valign="top" align="center" class="afitext"><img src="http://pics.10026.com/?src=/dvds/<%=RS("image")%>" border="1" width="100" height="140" alt="<%=RS("title")%>"><Br><%=RS("title")%><br><br></td>
<td valign="top" class="maintext"><p align="justify"><%=RS("body")%></p></td>
</tr>
<%
RS.MoveNext
Loop
End If
%>
</table>
</p
<%

Set RS = Nothing
Conn.Close
Set Conn = Nothing

%>Google for info on using a SQLDataReader to populate a repeater. That should give you what you need to do this in dotnet

No comments:

Post a Comment