D
dancer
Using ASP.net 1.1
2 QUESTIONS:
1. Why do my write commands not work?
2. This file successfully makes changes in the database record. There
surely is some simple code I could add that would *add* records to this
database. Who can tell me?
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data.Oledb" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim DBConnection As OledbConnection
DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;" & _
"Data Source=C:\Inetpub\wwwroot\app_data\Acc.mdb" )
DBConnection.Open()
Dim DBCommand As OledbCommand
DBCommand = New OledbCommand("SELECT * FROM table1, Acc")
Dim SQLString AS String
SQLString = "UPDATE Table1 SET TheEmpName='POOOOO' WHERE TheDate='6/14/07'"
DBCommand = New OleDBCommand(SQLString, DBConnection)
DBCommand.ExecuteNonquery()
Dim DBReader AS OledbDatareader
DBReader = DBCommand.ExecuteReader()
While DBReader.Read()
Response.Write(DBReader("TheDate"))
Response.Write(DBReader("TheEmpName"))
End while
' MyDataGrid.DataSource = DBReader
'MyDataGrid.DataBind()
DBReader.Close()
DBConnection.Close()
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<aspataGrid id="MyDataGrid" runat="server"/>
</form>
</body>
</html>
2 QUESTIONS:
1. Why do my write commands not work?
2. This file successfully makes changes in the database record. There
surely is some simple code I could add that would *add* records to this
database. Who can tell me?
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data.Oledb" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim DBConnection As OledbConnection
DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;" & _
"Data Source=C:\Inetpub\wwwroot\app_data\Acc.mdb" )
DBConnection.Open()
Dim DBCommand As OledbCommand
DBCommand = New OledbCommand("SELECT * FROM table1, Acc")
Dim SQLString AS String
SQLString = "UPDATE Table1 SET TheEmpName='POOOOO' WHERE TheDate='6/14/07'"
DBCommand = New OleDBCommand(SQLString, DBConnection)
DBCommand.ExecuteNonquery()
Dim DBReader AS OledbDatareader
DBReader = DBCommand.ExecuteReader()
While DBReader.Read()
Response.Write(DBReader("TheDate"))
Response.Write(DBReader("TheEmpName"))
End while
' MyDataGrid.DataSource = DBReader
'MyDataGrid.DataBind()
DBReader.Close()
DBConnection.Close()
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<aspataGrid id="MyDataGrid" runat="server"/>
</form>
</body>
</html>