ASP.Net Tutorials

Display records from an SQL database with a data grid

display_records_with_a_data_grid.aspx

<%@ import namespace="system.data.sqlClient" %>
<script runat="server">
sub page_load
dim myConnection as sqlConnection
dim myRecordSelect as sqlCommand
myConnection = new sqlConnection("SERVER=xxxxxxxx; UID=xxxxxxxx; PWD=xxxxxxxx; DATABASE=xxxxxxxx")
myRecordSelect = new sqlCommand("SELECT TOP 3 * FROM my_quotes", myConnection)
myConnection.open()
myRecords.dataSource = myRecordSelect.executeReader()
myRecords.dataBind()
myConnection.close()
end sub
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Display records with a data grid</title>
</head>

<body>

<asp:dataGrid id="myRecords" runat="server">
</asp:dataGrid>

</body>
</html>

Display records with a data grid
quote_idfirst_namelast_namequotesubject
1AnneSullivanI am beginning to suspect all elaborate and special systems of education. They seem to me to be built up on the supposition that every child is a kind of idiot who must be taught to think.education
2ArthurKoestlerCreativity is a type of learning process where the teacher and pupil are located in the same individual.education
3EdwardEverettEducation is a better safeguard of liberty than a standing army.education
ASP.Net
Other Tutorials