databases/dataadd.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 Add_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 = "INSERT INTO
Donor2000 VALUES('55555','Susan Ash', '12 Oak St', 'Braintree', 'MA',
'02184','1997', 'Ann Smith')"
'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
sub Show_Records(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>
<body>
<form
ID="NameForm" runat="server">
<asp:Button Text="Add"
OnClick="Add_Record" runat="server" />
<asp:Button Text="Display"
OnClick="Show_Records" runat="server" />
</form>
<asp:DataGrid
id="dgResults" runat="server" />
databases/dataadd1.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 Add_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 = "INSERT INTO
Donor2000 VALUES('" & idInput.Text & "', '" & nameInput.Text & "', '" &
adrInput.Text & "', '" & cityInput.Text & "',
'" & stateInput.Text & "', '" & zipInput.Text &
"', '" & yrfstInput.Text & "', '" &
contInput.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
sub Show_Records(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>
<body>
<form
ID="NameForm" runat="server">
Enter the Donor ID: <asp:TextBox id
="idInput" ForeColor="blue" runat="server"
/><br />
Enter the Donor Name: <asp:TextBox
id="nameInput" ForeColor="blue" runat="server"
/><br />
Enter the Donor Address: <asp:TextBox
id="adrInput" ForeColor="blue" runat="server"
/><br />
Enter the Donor City: <asp:TextBox
id="cityInput" ForeColor="blue" runat="server"
/><br />
Enter the Donor State: <asp:TextBox
id="stateInput" ForeColor="blue" runat="server"
/><br />
Enter the Donor ZIP: <asp:TextBox
id="zipInput" ForeColor="blue" runat="server"
/><br />
Enter the Donor Year First:
<asp:TextBox id="yrfstInput" ForeColor="blue"
runat="server" /><br />
Enter the Donor Contact: <asp:TextBox
id="contInput" ForeColor="blue" runat="server"
/><br />
<asp:Button Text="Add"
OnClick="Add_Record" runat="server" />
<asp:Button Text="Display"
OnClick="Show_Records" runat="server" />
</form>
<asp:DataGrid
id="dgResults" runat="server" />
databases/datadel.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 Add_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 = "DELETE FROM
Donor2000 WHERE DIdno = '55555'"
'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">
<asp:Button Text="Submit"
OnClick="Add_Record" runat="server" />
</form>
<asp:DataGrid
id="dgResults" runat="server" />
databases/datadel1.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 Delete_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 = "DELETE FROM
Donor2000 WHERE DIdno = " & "'" & idInput.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
sub Show_Records(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>
<body>
<form
ID="NameForm" runat="server">
Enter the Donor ID: <asp:TextBox id
="idInput" ForeColor="blue" runat="server"
/><br />
<asp:Button Text="Delete"
OnClick="Delete_Record" runat="server" />
<asp:Button Text="Display"
OnClick="Show_Records" runat="server" />
</form>
<asp:DataGrid
id="dgResults" runat="server" />
databases/datarelate1.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
Donor2000.DIdno, DName, DAmtCont FROM Donor2000, Donation2000 Where
Donor2000.DIdno = Donation2000.DIdno"
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" />
databases/datarelate1a.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
Donor2000.DIdno, DName, DAmtCont FROM Donor2000, " & _
"Donation2000 Where
Donor2000.DIdno = Donation2000.DIdno"
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" />
databases/datarelate2.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
Donor2000.DIdno, DName, Donation2000.DDriveNo, DDriveName, DAmtCont FROM
Donor2000, Donation2000, Drive2000 Where Donor2000.DIdno = Donation2000.DIdno
and Donation2000.DDriveNo = Drive2000.DDriveNo"
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" />