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 January 4th, 2006, 05:08 AM
Authorized User
 
Join Date: Jan 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, but with this code the Previous error remains the same

<%'Establish database connection-------

    Dim objrs, objcon,strcon,Id,orderno

     Set objcon = Server.CreateObject("ADODB.Connection")
    strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Inetpub\wwwroot\project\Id.mdb;"
    objcon.Open strcon

    Id=Request.Form("Id")
    orderno=Request.Form("orderno")
    strdml="INSERT INTO Id (orderno,Id) VALUES (orderno,Id)"
    objcon.Execute strdml

objcon.Close
  Set objcon = nothing
%>


 
Old January 4th, 2006, 05:20 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Like I said, look at the line that starts with

strdml ="Insert into Customers

That builds up a SQL statement and then adds the values of the variables to that string using concatenation (the & character).

You need to do that too, right now you pass the text orderno and Id, but you need to pass their values.

Can you please NOT send me a copy of each post on my personal E-mail address? Thanks,

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

I don't want to sound rude, but if you can't read, and more importantly, can't listen, I doubt that you'll make your dead-line today.

I asked it once here, and twice in a personal message: CAN YOU PLEASE STOP SENDING ME A COPY OF EACH POST TO MY PRIVATE E-MAIL!!!!! Sorry all for shouting, but asking the same thing three times gets me angry. If you don't, I stop answering your questions and ignore you.

Re your other question: I think type is a reserved keyword....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 4th, 2006, 07:46 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to djatsii Send a message via Yahoo to djatsii
Default

error: Field 'Customers.CustomerID' cannot be a zero-length string...
 thanks imar...

jacky
 
Old January 4th, 2006, 07:58 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Sounds like the value of the Customer ID is not correctly added to the SQL statement. Can you use Response.Write(strdml) to write out the value for the SQL statement again?

That helps tremendously in debugging the SQL statement. Then copy it from your browser in your database, and you'll be able to see what's going wrong.

If that doesn't help, post the code to this thread....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 4th, 2006, 10:17 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to djatsii Send a message via Yahoo to djatsii
Default

<html>

 <%
    '***********************************
    ' 1 Step Connect the Database
    '***********************************

     set conn = Server.CreateObject("Adodb.Connection")
     conn.ConnectionString="Provider=Microsoft.Jet.OLED B.4.0;Data Source=c:\inetpub\wwwroot\ssc.mdb;Persist Security Info=False"

     conn.open



    '***********************************
    ' 2 Execute Insert Command
    '***********************************

        dim strdml
    dim xcustomer_id
    dim xcompany_name
    dim xcontact_name
    dim xcontact_title
    dim xaddress
    dim xcity
    dim xregion
    dim xpostal_code
    dim xcountry
    dim xphone
    dim xfax


    xcustomer_id = request.form("txtCustomerId")
    xcompany_name = request.form("txtCompanyName")
    xcontact_name = request.form("txtContactName")
    xcontact_title = request.form("txtContactTitle")
    xaddress = request.form("txtAddress")
    xcity = request.form("txtCity")
    xregion = request.form("txtRegion")
    xpostal_code = request.form("txtPostalCode")
    xcountry = request.form("txtCountry")
    xphone = request.form("txtPhone")
    xfax = request.form("txtFax")

    strdml ="Insert into Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax) Values('"&xcustomer_id&"', '" &xcompany_name& "', '" &xcontact_name& "', '" &xcontact_title& "', '" &xaddress& "', '" &xcity& "', '" &xregion& "', '" &xpostal_code& "', '" &xcountry& "', '" &xphone& "', '" &xfax&"')"

    'RESPONSE.WRITE(STRDML)
    conn.execute strdml

    conn.close

 %>


<center><h1>Record Successfully Inserted</h1></center>


</html>

Error Type:
Microsoft JET Database Engine (0x80004005)
Field 'Customers.CustomerID' cannot be a zero-length string.
/add.asp, line 48

>>>Respose.Write(strdml)

Insert into Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax) Values('', '', '', '', '', '', '', '', '', '', '')

jacky
 
Old January 4th, 2006, 05:49 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Isn't it obvious from the error message and the code you posted what the problem is??

These are the values for your INSERT statement:

('', '', '', '', '', '', '', '', '', '', '')

This is the error message:

Field 'Customers.CustomerID' cannot be a zero-length string.

You're not passing a value for the Customers.CustomerID field (and not for the other fields too).

Apparently, your variables never get a value. This can be caused by a couple of reasons:

1. Your form fields have different names then the ones you try to access.

2. This is more likely the cause: you already run the INSERT statement when the page first loads. To fix that, make sure you run the code only when the Save button is clicked. Something like this will work (with a submit button called btnSubmit)

If Request.Form("btnSubmit") <> "" Then
' Run your INSERT statement here.
End If

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Some help required ! codenet C# 2005 1 September 24th, 2007 04:01 PM
No value given for one or more required parameters ableton ADO.NET 2 July 18th, 2006 02:12 AM
No value given for one or more required parameters imercha Classic ASP Databases 1 December 21st, 2005 06:44 PM
No value given for one or more required parameters vlado Classic ASP Databases 10 October 5th, 2004 09:10 PM
No value given for one or more required parameters nidy_online ADO.NET 1 June 27th, 2004 09:44 AM





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