| Dustin James ( @ 2009-05-16 14:26:00 |
Biggest Hurdle to adopting ASP.Net
One of my biggest hurdles to adopting ASP.net as my primary coding language was the database access layer. I'm an ASP (VB Flavor) guy through and through, but ASP.net cut out the recordset object by moving to ADO.net, and nearly all of the examples I ever saw on how to connect up to a db were to throw the results into a datagrid.
But I didn't want to display in a datagrid and reference by some hack bullshit Object Oriented way of just trying to get the first TD cell to change it's font style to bold... I wanted to iterate through a recordset! I also don't use Visual Studio, I don't believe that you should have to depend on an IDE in order to do work. Most of the people I work with who have learned ASP.net through an IDE have no concept on how to code, they just "drag and drop" and "Visual Studio does it all for me". MEH! The first time their shit breaks, or doesn't look right on a browser, or the javascript that ASP.net writes for them doesn't execute properly, they are completely f'n lost.
Anyway, I finally sat down Friday and put my head to how I can best mimic hooking up a database to ASP.net in the ASP feel, and I finally feel comfortable doing it. Now that I know how to iterate through recordsets, I may make my next project in ASP.NET.
If anyone wants to know, here's how I figured out how to iterate through records similar to ASP:
<%@ Page Explicit="false"%>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<%
DSN="server=localhost; user id=User; password=UserPassword; database=DB_Customers;"
Connection = New MySqlConnection(DSN)
Connection.Open()
SQL = "select * from tbl_customers limit 10;"
Query = New MySqlCommand(SQL, Connection)
RS = Query.ExecuteReader()
%>
<table cellspacing="2" cellpadding="2" border="1">
<tr>
<td>ID</td>
<td>First Name</td>
<td>Last Name</td>
</tr>
<%
Do while RS.Read()
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("first_name")%></td>
<td><%=rs("last_name")%></td>
</tr>
<%
Loop
RS.Close
Connection.Close
%>
</table>
One of my biggest hurdles to adopting ASP.net as my primary coding language was the database access layer. I'm an ASP (VB Flavor) guy through and through, but ASP.net cut out the recordset object by moving to ADO.net, and nearly all of the examples I ever saw on how to connect up to a db were to throw the results into a datagrid.
But I didn't want to display in a datagrid and reference by some hack bullshit Object Oriented way of just trying to get the first TD cell to change it's font style to bold... I wanted to iterate through a recordset! I also don't use Visual Studio, I don't believe that you should have to depend on an IDE in order to do work. Most of the people I work with who have learned ASP.net through an IDE have no concept on how to code, they just "drag and drop" and "Visual Studio does it all for me". MEH! The first time their shit breaks, or doesn't look right on a browser, or the javascript that ASP.net writes for them doesn't execute properly, they are completely f'n lost.
Anyway, I finally sat down Friday and put my head to how I can best mimic hooking up a database to ASP.net in the ASP feel, and I finally feel comfortable doing it. Now that I know how to iterate through recordsets, I may make my next project in ASP.NET.
If anyone wants to know, here's how I figured out how to iterate through records similar to ASP:
<%@ Page Explicit="false"%>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<%
DSN="server=localhost; user id=User; password=UserPassword; database=DB_Customers;"
Connection = New MySqlConnection(DSN)
Connection.Open()
SQL = "select * from tbl_customers limit 10;"
Query = New MySqlCommand(SQL, Connection)
RS = Query.ExecuteReader()
%>
<table cellspacing="2" cellpadding="2" border="1">
<tr>
<td>ID</td>
<td>First Name</td>
<td>Last Name</td>
</tr>
<%
Do while RS.Read()
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("first_name")%></td>
<td><%=rs("last_name")%></td>
</tr>
<%
Loop
RS.Close
Connection.Close
%>
</table>