database/brink1.aspx
<%@ Import
Namespace="System.Data" %>
<%@ Import
Namespace="System.Data.OleDB" %>
<Script
Runat="Server">
Sub Page_Load
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; DATA Source=" & sPath &
";"
Dim objConn As OleDbConnection
Dim cmdSelect As OleDbCommand
Dim dtrReader As OleDbDataReader
Dim strResults As String
objConn = New OleDbConnection( connString
)
objConn.Open()
cmdSelect= New OleDbCommand( "SELECT
DName From Donor2000", objConn)
dtrReader= cmdSelect.ExecuteReader()
While dtrReader.Read()
strResults = strResults &
dtrReader("DName") & "<br>"
End While
lblResults.Text = strResults
dtrReader.Close()
objConn.Close()
End Sub
</Script>
<html>
<body>
<asp:Label
id="lblResults" Runat="Server"/>
</body>
</html>
database/brink2.aspx
<%@ Import
Namespace="System.Data" %>
<%@ Import
Namespace="System.Data.OleDB" %>
<Script
Runat="Server">
Sub Page_Load
Dim sPath As String = Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; DATA Source=" & sPath &
";"
Dim objConn As OleDbConnection
Dim cmdSelect As OleDbCommand
Dim dtrReader As OleDbDataReader
Dim strResults As String
objConn = New OleDbConnection( connString )
objConn.Open()
cmdSelect= New OleDbCommand( "SELECT
DIdno, DName From Donor2000", objConn)
dtrReader= cmdSelect.ExecuteReader()
While dtrReader.Read()
strResults = strResults &
dtrReader("DIdno") & " "
&dtrReader("DName") & "<br>"
End While
lblResults.Text = strResults
dtrReader.Close()
objConn.Close()
End Sub
</Script>
<html>
<body>
<asp:Label
id="lblResults" Runat="Server"/>
</body>
</html>
database/datatest.aspx
<%@ Import Namespace="System.Data"
%>
<%@ Import
Namespace="System.Data.OleDb" %>
<script
language="VB" runat="server">
sub Page_Load(sender as Object, e as
EventArgs)
'Create a connection string
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim
connString as String
connString =
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & sPath &
";"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New
OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL as String = "SELECT * FROM
Donor2000"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL,
objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Do the DataBinding
dgResults.DataSource = objDataReader
dgResults.DataBind()
'Close the datareader/db connection
objDataReader.Close()
end sub
</script>
<asp:DataGrid
id="dgResults" runat="server" />
database/datatest1.aspx
<%@ Import
Namespace="System.Data" %>
<%@ Import
Namespace="System.Data.OleDb" %>
<script
language="VB" runat="server">
sub Page_Load(sender as Object, e as
EventArgs)
'Create a connection string
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString as String
connString =
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & sPath &
";"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New
OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL as String = "SELECT DIdno,
DName, DYrFirst FROM Donor2000 where DYrFirst =" & "'1996'"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL,
objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Do the DataBinding
dgResults.DataSource = objDataReader
dgResults.DataBind()
'Close the datareader/db connection
objDataReader.Close()
end sub
</script>
<asp:DataGrid
id="dgResults" runat="server" />
database/datatest2.aspx
<%@ Import
Namespace="System.Data" %>
<%@ Import
Namespace="System.Data.OleDb" %>
<script
language="VB" runat="server">
sub Page_Load(sender as Object, e as
EventArgs)
'Create a connection string
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString as String
connString =
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & sPath &
";"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL as String = "SELECT DIdno,
DName, DYrFirst FROM Donor2000 order by DYrFirst"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL,
objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Do the DataBinding
dgResults.DataSource = objDataReader
dgResults.DataBind()
'Close the datareader/db connection
objDataReader.Close()
end sub
</script>
<asp:DataGrid
id="dgResults" runat="server" />
database/datatest2.aspx
<%@ Import
Namespace="System.Data" %>
<%@ Import
Namespace="System.Data.OleDb" %>
<script
language="VB" runat="server">
sub Page_Load(sender as Object, e as
EventArgs)
'Create a connection string
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString as String
connString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=" & sPath & ";"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New
OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL as String = "SELECT DIdno,
DName, DYrFirst FROM Donor2000 order by DYrFirst"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL,
objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Do the DataBinding
dgResults.DataSource = objDataReader
dgResults.DataBind()
'Close the datareader/db connection
objDataReader.Close()
end sub
</script>
<asp:DataGrid
id="dgResults" runat="server" />
database/datatest3.aspx
<%@ Import
Namespace="System.Data" %>
<%@ Import
Namespace="System.Data.OleDb" %>
<script
language="VB" runat="server">
sub Page_Load(sender as Object, e as
EventArgs)
'Create a connection string
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString as String
connString =
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & sPath &
";"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New
OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL as String = "SELECT DName,
DCity FROM Donor2000 Where DCity = " & "'Fall River'" &
" or " & "Dcity = " & "'Braintree'"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL,
objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Do the DataBinding
dgResults.DataSource = objDataReader
dgResults.DataBind()
'Close the datareader/db connection
objDataReader.Close()
end sub
</script>
<asp:DataGrid
id="dgResults" runat="server" />
database/datatest4.aspx
<%@ Import
Namespace="System.Data" %>
<%@ Import
Namespace="System.Data.OleDb" %>
<script
language="VB" runat="server">
sub Page_Load(sender as Object, e as
EventArgs)
'Create a connection string
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString as String
connString =
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & sPath &
";"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New
OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL as String = "SELECT * FROM
Donor2000"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL, objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Do the DataBinding
dgResults.DataSource = objDataReader
dgResults.DataBind()
end sub
sub Get_Record(sender as Object, e as
EventArgs)
'Create a connection string
Dim sPath As String =
Server.MapPath("\pgrocer\db\donor.mdb")
Dim connString as String
connString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=" & sPath & ";"
'Open a connection
Dim objConnection as OleDbConnection
objConnection = New
OleDbConnection(connString)
objConnection.Open()
'Specify the SQL string
Dim strSQL as String = "SELECT * FROM
Donor2000 where DName = '" & nameInput.Text & "'"
'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL,
objConnection)
'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Do the DataBinding
dgResults.DataSource = objDataReader
dgResults.DataBind()
'Close the datareader/db connection
objDataReader.Close()
end
sub
</script>
<body>
<form
ID="NameForm" runat="server">
Enter the Donor Name: <asp:TextBox
id="nameInput" ForeColor="blue" runat="server"
/>
<asp:Button Text="Submit"
OnClick="Get_Record" runat="server" />
</form>
<asp:DataGrid id="dgResults" runat="server" />