Subject: No value given for one or more required parameters
Posted By: djatsii Post Date: 12/30/2005 8:21:26 AM
need help... what am I doing wrong? thanks in advance...

<html>

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

     set conn = Server.CreateObject("Adodb.Connection")
     conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.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("txtcustid")
    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(Customer_ID, Company_Name, Contact_Name, Contact_Title, Address, City, Region, Postal_Code, Country, Phone, Fax) values("&xcustomer_id&",'"&xcompany_name&"','"&xcontact_name&"','"&xcontact_title&"','"&xaddress&"','"&xcity&"','"&xregion&"','"&xpostal_code&"','"&xcountry&"','"&xphone&"','"&xfax&"')"

    conn.execute strdml  

    conn.close

 %>


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


jacky
Reply By: djatsii Reply Date: 12/30/2005 8:45:23 AM
by the way, customer_ID is a string, thanks

jacky
Reply By: Imar Reply Date: 12/30/2005 8:58:58 AM
quote:
by the way, customer_ID is a string
In that case, you should enclose the value in single quotes, just like you did with other columns.

If that doesn't help, write out strdml using Response.Write(strdml) and post the results of that to this thread.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply By: djatsii Reply Date: 12/30/2005 12:05:17 PM
Insert into Customers(Customer_ID, Company_Name, Contact_Name, Contact_Title, Address, City, Region, Postal_Code, Country, Phone, Fax) values(this is customer id,'this is company name','this is contact name','','this is address','this is a city','this is a region','05012','this is a country','7243061','1535556')
Record Successfully Inserted



thanks :)

jacky
Reply By: djatsii Reply Date: 12/30/2005 12:12:52 PM
it's not retrieving contact_title.... ???? :(

jacky
Reply By: Imar Reply Date: 12/30/2005 2:36:16 PM
Indeed the title seems empty. However, this is more likely the problem:
quote:
In that case, you should enclose the value in single quotes, just like you did with other columns.
You haven't done that yet...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply By: djatsii Reply Date: 1/3/2006 9:45:35 AM
which value should i enclose with single quotes? sorry about that...

jacky
Reply By: Imar Reply Date: 1/3/2006 9:58:44 AM
The Customer_ID. Take a look at this:

values(this is customer id,'this

As you can see, this is customer is not enclosed in quotes, so the database has no idea what you're saying.

Change it to:

values('this is customer id','this

Basically, only numeric fields do not use quotes...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply By: Ashwini Reply Date: 1/4/2006 3:46:30 AM

<form method="post">
Id :<input type="text" name="Id" size=10>
Order NO:<input type="text" name="orderno" size=10>
<input type="submit" value="Submit">
</form>


<%'Establish database connection-------
   
    Dim objrs, objcon,strcon,Id,orderno
    
    Id = Request.Form("Id")
    orderno=Request.Form("orderno")
     
    strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Inetpub\wwwroot\project\Id.mdb;"
    Set objcon = Server.CreateObject("ADODB.Command")
    objcon.ActiveConnection= strcon
    objcon.CommandText="INSERT INTO Id (orderno,Id) VALUES (orderno,Id)"
    Set objrs = objcon.Execute
    objcon.CommandText="select * From Id"  
    set objrs=objcon.Execute
    while not objrs.EOF
    Response.write objrs ("Id")
    Response.write objrs ("orderno")
   objrs.MoveNext
    wend
   

    objrs.Close
   set objrs = nothing
  
  'objcon.Close
  Set objcon = nothing
%>    

This is my code  & the error cmes with this is
Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
/project/order.asp, line 15

Please help because i have to finish it today


Reply By: Imar Reply Date: 1/4/2006 3:52:41 AM
Hi there,

Look at the first post made by djatsii and look at the line that starts with

strdml ="Insert into

That should give you a clue as to how you should build your SQL statement as this:

objcon.CommandText="INSERT INTO Id (orderno,Id) VALUES (orderno,Id)"

clearly doesn't work. You need to add the values of orderno and Id to the SQL statement.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply By: Ashwini Reply Date: 1/4/2006 4:08:49 AM
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
%>


Reply By: Imar Reply Date: 1/4/2006 4:20:52 AM
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.
Reply By: Imar Reply Date: 1/4/2006 5:59:45 AM
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.
Reply By: djatsii Reply Date: 1/4/2006 6:46:07 AM
error: Field 'Customers.CustomerID' cannot be a zero-length string...
 thanks imar...

jacky
Reply By: Imar Reply Date: 1/4/2006 6:58:10 AM
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.
Reply By: djatsii Reply Date: 1/4/2006 9:17:30 AM
<html>

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

     set conn = Server.CreateObject("Adodb.Connection")
     conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.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
Reply By: Imar Reply Date: 1/4/2006 4:49:42 PM
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.

Go to topic 38262

Return to index page 403
Return to index page 402
Return to index page 401
Return to index page 400
Return to index page 399
Return to index page 398
Return to index page 397
Return to index page 396
Return to index page 395
Return to index page 394