i made the changes in the SQL Statement and in the table but i'm still recieving the error msg: "The INSERT INTO statement contains the following unknown field name: 'User1'. Make sure you have typed the name correctly, and try the operation again.", i'm not sure what i'm doing wrong becasue i followed the same proccess to change Update anf that seems to be working fine, here is a look at my code as it has changed
<%@ Page Language="c#" Debug="True" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
OleDbConnection objConnection;
private void Page_Load(object sender, System.EventArgs e)
{
objConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=AAC.mdb");
}
private void btnInsert_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
String strSQL = "INSERT INTO Computers (Location, User1, TypeOfComputer, Manufacturer, ModelNumber, SerialNumber, DatePurchased, DateGarunteed, DateMaintenence, CPU, Memory, HardDrive, CDROM, SoundCard, VideoCard, NetworkID, PrinterType, OtherEquipment, OS, ApplicationSoftware, NetworkCard, NetworkConnection, HardwareUpdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
OleDbCommand dbComm = new OleDbCommand(strSQL, objConnection);
dbComm.Parameters.Add("Location", OleDbType.VarChar, 32, "Location");
dbComm.Parameters.Add("User1", OleDbType.VarChar, 32, "User1");
........
dbComm.Parameters.Add("HardwareUpdate", OleDbType.VarChar, 32, "HardwareUpdate");
dbComm.Parameters["Location"].Value = txtLocation.Text;
dbComm.Parameters["User1"].Value = txtUser1.Text;
......
dbComm.Parameters["HardwareUpdate"].Value = txtHardwareUpdate.Text;
int iID = 0;
try
{
objConnection.Open();
dbComm.ExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex.Message);
Response.End();
}
finally
{
if (objConnection.State == ConnectionState.Open);
objConnection.Close();
}
Response.Write("A new record has been added");
Response.End();
}
}
</script>
<html>
<head>
<title>Validating a Feild</title>
</head>
<body>
<form id="Form1" methode="post" runat="server">
<table id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" cellspacing="0" cellpadding="0" width="300" border="0">
<tbody>
<tr>
<td style="WIDTH: 115px">
<asp:Label id="Label1" runat="server">Location</asp:Label></td>
<td>
<asp:TextBox id="txtLocation" runat="server" width="193"></asp:TextBox>
</td>
</tr>
<tr>
<td style="WIDTH: 115px">
<asp:Label id="Label2" runat="server">User1</asp:Label></td>
<td>
<asp:TextBox id="txtUser1" runat="server" width="193"></asp:TextBox>
</td>
</tr>
.......
<tr>
<td style="WIDTH: 115px">
<asp:Label id="Label23" runat="server">HardwareUpdate</asp:Label></td>
<td>
<asp:TextBox id="txtHardwareUpdate" runat="server" width="193"></asp:TextBox>
</td>
</tr>
<tr>
<td style="WIDTH: 115px" colspan="2">
<asp:Button id="btnInsert" onclick="btnInsert_Click" runat="server" width="298px" Height="27px" text="INSERT!"></asp:Button>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
|