R
Rich
Hello,
I have a test aspx page with 2 textboxes which will update
an Access mdb table (which contains several fields but I
work with the following fields):
txtID, txtCity, txtZip
I set param0 to txtID, param1 to txtzip. Then I enter data
in the textboxes (txtID and txtZip) to update the zip
field in a row based on the ID. But when I enter data and
update, param0 references txtZip, param1 references
txtID. Any ideas what is going on? Here is my listing -
Am I missing something? Isn't txtID supposed to be the
first textbox I list and txtZip the second one?:
------------------------------------------------------
<%@ Import Namespace="System.Data.Oledb" %>
<%@ Page Language="VB" Debug="true" %>
<Script Runat="Server">
Sub Button_Click( s As Object, e As EventArgs )
Dim conn As OleDbConnection
Dim cmdUpdate As OleDbCommand
Dim strSql As String
conn = New OleDBconnection
("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
Source=F:\AspNet\db\Members.mdb")
strSql = "Update tblCenter Set Zip=@p1 Where ID=@p0"
cmdUpdate = New OleDbCommand(strSql, conn)
cmdUpdate.Parameters.Add( "@p0", txtID.Text )
cmdUpdate.Parameters.Add( "@p1", txtZip.Text )
conn.Open()
cmdUpdate.ExecuteNonQuery()
conn.Close()
End Sub
</Script>
<html>
<head><title>test1.aspx</title></head>
<body>
<form Runat="Server">
<b>ID:</b>
<asp:TextBox ID="txtID" Runat="Server" />
<br>
<b>Zip:</b>
<asp:TextBox ID="txtZip" Runat="Server" />
<br>
<asp:Button Text="Update" OnClick="Button_Click"
Runat="Server" />
</form>
</body>
</html>
I have a test aspx page with 2 textboxes which will update
an Access mdb table (which contains several fields but I
work with the following fields):
txtID, txtCity, txtZip
I set param0 to txtID, param1 to txtzip. Then I enter data
in the textboxes (txtID and txtZip) to update the zip
field in a row based on the ID. But when I enter data and
update, param0 references txtZip, param1 references
txtID. Any ideas what is going on? Here is my listing -
Am I missing something? Isn't txtID supposed to be the
first textbox I list and txtZip the second one?:
------------------------------------------------------
<%@ Import Namespace="System.Data.Oledb" %>
<%@ Page Language="VB" Debug="true" %>
<Script Runat="Server">
Sub Button_Click( s As Object, e As EventArgs )
Dim conn As OleDbConnection
Dim cmdUpdate As OleDbCommand
Dim strSql As String
conn = New OleDBconnection
("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
Source=F:\AspNet\db\Members.mdb")
strSql = "Update tblCenter Set Zip=@p1 Where ID=@p0"
cmdUpdate = New OleDbCommand(strSql, conn)
cmdUpdate.Parameters.Add( "@p0", txtID.Text )
cmdUpdate.Parameters.Add( "@p1", txtZip.Text )
conn.Open()
cmdUpdate.ExecuteNonQuery()
conn.Close()
End Sub
</Script>
<html>
<head><title>test1.aspx</title></head>
<body>
<form Runat="Server">
<b>ID:</b>
<asp:TextBox ID="txtID" Runat="Server" />
<br>
<b>Zip:</b>
<asp:TextBox ID="txtZip" Runat="Server" />
<br>
<asp:Button Text="Update" OnClick="Button_Click"
Runat="Server" />
</form>
</body>
</html>