Since I don't run the server, I can't go in and change things (plus I'm learning this) so one objective was to have everything on one page. I expect any future discuss to mention there are drawbacks to this--please consider this just a "starter".
History: Two days digging through tutorials, learning things, a few hours ago I found something for Microsoft Access but another page showed comparisons so I took the gamble, to convert it over--and it worked.
However, a few weeks ago I learned that PHP pages that worked were not necessarily the best (in terms of safety and/or efficiency).
Comment about not all queries working deleted--it was fixed the next morning.
Here's the code, in case another newbie wants to try it, or if a highly skilled expert can look at it and immediately see opportunities for improvement:
(it isn't PHP, it's ASP.NET but I'm thinking you'll want the colors)
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New SqlConnection("Server=somename.secureserver.net; uid=username; pwd=password; database=DB_123456")
dbconn.Open()
sql="SELECT * FROM separation ORDER BY last_name ASC"
dbcomm=New SqlCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
actors.DataSource=dbread
actors.DataBind()
dbread.Close()
dbconn.Close()
end sub
</script>
<html>
<body>
<form runat="server">
<asp:Repeater id="actors" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<th>First Name</th>
<th>Last Name</th>
<th>Movie</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("first_name")%> </td>
<td><%#Container.DataItem("last_name")%> </td>
<td><%#Container.DataItem("movie")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
I'll be coming through later and adding comments on the various types of "things" above. I'm not an expert so this shouldn't be considered a tutorial. I'm somewhat assuming if this is new to you, you may be coming here with some knowledge of PHP, so some comments will be "compare and contrast" to PHP.
Namespace="System.Data.SqlClient"
Reference: http://msdn2.microsoft.com/en-us/library...lient.aspx
Initially I used this to identify if a page was coded for SQL Server, or something else like Microsoft Access or Oracle.
<form runat="server"> </form>
So far I've only seen this with "server" (tried Googling to get an alternate)
sub Page_Load or sub end sub
Still looking to find something that talks specifically about this.
dim
used to declare variables (as int, single, double)
Kind of begs the question, how come the code doesn't say what dbconn,sql,dbcomm,dbread are supposed to be--unless we find out later that they default to something if nothing is said
caution: there are two similarly named variables: dbconn, dbcomm
In MySQL, making a connection required two commands: mysql_connect($server, $username, $password); mysql_select_db($database_name);
The same four entities are used in one command, New SqlConnection.
sql is a query (at this point I started noticing the lack of a $ sign for string.)
I kind of don't want to say it (in case I'm wording it wrong) but it looks like dbread is something that opens something, because a few lines later it was necessary close it.
My reading so far suggests the need to deliberately close a database. A few weeks ago it was mentioned that with PHP and MySQL, a connection only had to be closed if it was a persistent connection.
The component actors in two commands comes from the id in the <asp: repeater
databinding-
http://www.akadia.com/services/dotnet_da...l#Overview
asp:repeater
(Later) One of the reasons I wanted this to work from a single page, was that some of the things I read (like: go in and change file X) might be things someone who depended on a provider couldn't do. Tutorials kept refering to a web.config file. I hadn't seen one on my site, so I thought maybe I didn't have access to it. However, while working on a different problem today, I found that it was a simple matter of going to the root director and adding a web.config file (edited using text editor and being sure to save it using "save as type: all files"). I haven't tried using web.config to store my connection information, but this is fairly close to the top of my list of priorities.
- - -
(version 2)
It was suggested that I use Gridview instead of the above HTML:
My reference for GridView: http://aspnet101.com/aspnet101/tutorials.aspx?id=51
And an .aspx page with it that worked:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView id="MyGridView" DataSourceID="MyDataSource1" Runat="Server"/>
<asp:SqlDataSource ID="MyDataSource1" runat="server"
ConnectionString="Server=something.secureserver.net;uid=username;pwd=password;database=DB_123456"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT * FROM tablename">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>[/code
]
General reference:
http://www.newobjects.com/pages/ndl/alp/...ucture.htm

