Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2003, 04:47 PM
aac aac is offline
Authorized User
 
Join Date: Jun 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>

 
Old July 18th, 2003, 03:23 PM
aac aac is offline
Authorized User
 
Join Date: Jun 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

does anyone have good idea as to why this might be, i wrote another page that didn't handle as much information in the same format and it worked fine, but this page has yet to work at all






Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of an obje GS C# 2005 3 May 21st, 2007 10:11 AM
Object reference not set to an instance of an obje rturner003 ASP.NET 2.0 Professional 0 December 26th, 2006 08:30 PM
Object reference not set to an instance of an obje williadn General .NET 0 January 18th, 2005 05:39 PM
Object reference not set to an instance of an obje bekim Classic ASP Basics 1 August 9th, 2004 01:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.