Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 December 24th, 2003, 03:35 PM
Authorized User
 
Join Date: Dec 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default C#-direct SQL - ExecuteNonQuery()

can somebody tell me whats wrong with this direct SQL code i took from book. its showing error at the line

   objCmd.ExecuteNonQuery();

OleDbException (0x80040e10): No value given for one or more required parameters.

---------------------------------------------------

<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    void Page_Load(object sender, EventArgs e)
     {
       OleDbConnection objConnection = null;
       OleDbCommand objCmd = null;

       string strConnection, strSQL;
       strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
       strConnection += @"Data Source=C:\Documents and Settings\Jenu\Desktop\testing\northwind.mdb";

       // Create and open the connection object

       objConnection = new OleDbConnection(strConnection);
       objConnection.Open();

       // Set the SQL string
       strSQL = "INSERT INTO Employees (FirstName,LastName) VALUES ( `Beth` , `Hart` )";

       // Create the Command and set its properties

       objCmd = new OleDbCommand(strSQL, objConnection);

       // Execute the command


       objCmd.ExecuteNonQuery();


       lblStatus.Text = " Command run ";
     }

</script>
<html>
<head>
</head>
<body>
    <h2>Using SQL directly
    </h2>
    <asp:Label id="lblStatus" runat="server"></asp:Label>
</body>
</html>
 
Old December 29th, 2003, 10:55 AM
Authorized User
 
Join Date: Dec 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

guys I'm still waiting for some help....
coudnt figure out what parameter its asking for
 
Old December 29th, 2003, 11:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look here: http://www.adopenstatic.com/faq/80040e10.asp
It discusses various solutions to 80040e10 errors.

Another thing to check are the access rights to your database. The Web server will use the IUSR_MachineName account where MachineName is the name of your computer. Depending on your set up, this account does not have permission to access your desktop. If I were you, I'd move the database to a specific folder (e.g. c:\Databases) and then set the correct permissions on that folder. IUSR_MachineName needs at least change permission on the Databases folder to change the .MDB file and to create lock file (.ldb).

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 29th, 2003, 11:03 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

One more thing to check:
Code:
strSQL = "INSERT INTO Employees (FirstName,LastName) VALUES ( `Beth` , `Hart` )";
I don't think you can use these extended quotes. Change it to this:
Code:
strSQL = "INSERT INTO Employees (FirstName,LastName) VALUES ('Beth', 'Hart')";
Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 29th, 2003, 08:45 PM
Authorized User
 
Join Date: Dec 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot....
that was an invisible error
the code worked





Similar Threads
Thread Thread Starter Forum Replies Last Post
Expaning on ExecuteNonQuery () in DataAccess class kalel_4444 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 July 21st, 2008 03:52 PM
Using a form field to direct an INSERT INTO SQL GusGray Access VBA 2 January 25th, 2008 09:50 AM
Chapter-13-direct SQL command-ExecuteNonQuery erro lionking BOOK: Beginning ASP.NET 1.0 3 May 13th, 2004 10:42 PM
Chapter-13-direct SQL command-ExecuteNonQuery erro softdev BOOK: Beginning ASP.NET 1.0 6 February 22nd, 2004 07:55 PM
OleDbCommand.ExecuteNonQuery(); kaz VS.NET 2002/2003 1 December 7th, 2003 04:29 PM





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