#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2007
    Posts
    12
    Rep Power
    0

    Plz help I am beginner in ASP


    Hi,
    All

    I want to insert data into two different tables but i got error.
    I have two tables one is Order_master and another is Order_detail.
    Order_Id field of Order_master table is primary key and Order_Id field of Order_detail table is reference of Order_master table but I got following error

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.


    My code is:

    Code:
    <%
    if request.QueryString("command")="addrecord" then
    
    Duplicate=False
    success=false
    
    set rsadd = server.CreateObject("ADodb.recordset")
    rsadd.open "select * from Order_master where Cust_Name = '"&Request.Form("name")&"' AND Cust_TelNo = '"&Request.Form("telno")&"' AND Cust_ShippingAdd = '"&Request.Form("shippingadd")&"' AND Name_CreditCard = '"&Request.Form("creditcardname")&"' AND CreditCard_BillingAdd = '"&Request.Form("billingadd")&"' AND Email = '"&Request.Form("email")&"' AND CreditCard_Type = '"&Request.Form("creditcardtype")&"' AND Order_Status = '"&Request.Form("status")&"'",cn,1,3,1
    'rsadd.open "select * from Order_master a AND Order_detail b where a.Cust_Name = '"&Request.Form("name")&"' AND a.Cust_TelNo = '"&Request.Form("telno")&"' AND a.Cust_ShippingAdd= '"&Request.Form("shippingadd")&"' AND a.Name_CreditCard = '"&Request.Form("creditcardname")&"' AND a.CreditCard_BillingAdd= '"&Request.Form("billingadd")&"' AND a.Email = '"&Request.Form("email")&"' AND a.CreditCard_Type = '"&Request.Form("creditcardtype")&"' AND a.Order_Status= '"&Request.Form("status")&"' AND b.Order_Id= '"&Request.Form("Order_Id")&"' AND b.Item_Name = '"&Request.Form("itemname")&"' AND b.Item_Type= '"&Request.Form("itemtype")&"' AND b.Item_UnitPrice = '"&Request.Form("price")&"' AND b.Item_Qty = '"&Request.Form("quantity")&"' ",cn,1,3,1
    
    if rsadd.eof then
    rsadd.addnew
    rsadd("Cust_Name")=Request.Form("name")
    rsadd("Cust_TelNo")=Request.Form("telno")
    rsadd("Cust_ShippingAdd")=Request.Form("shippingad d")
    rsadd("Name_CreditCard")=Request.Form("creditcardn ame")
    rsadd("CreditCard_BillingAdd")=Request.Form("billi ngadd")
    rsadd("Email")=Request.Form("email")
    rsadd("CreditCard_Type")=Request.Form("creditcardt ype")
    rsadd("Order_Status")=Request.Form("status")
    rsadd.update
    rsadd.movenext
    
    
    set rsadd1 = server.CreateObject("ADodb.recordset")
    rsadd1.open "select * from Order_detail where Order_Id='"&int(Request.Form("Order_Id"))&"' AND Item_Name = '"&Request.Form("itemname")&"' AND Item_Type = '"&Request.Form("itemtype")&"' AND Item_UnitPrice= '"&Request.Form("price")&"' AND Item_Qty= '"&Request.Form("quantity")&"' ",cn,1,3,1
    
    if rsadd1.eof then
    rsadd1.addnew
    rsadd1("Order_Id")=Request.Form("Order_Id")
    rsadd1("Item_Name")=Request.Form("itemname")
    rsadd1("Item_Type")=Request.Form("itemtype")
    rsadd1("Item_UnitPrice")=Request.Form("price")
    rsadd1("Item_Qty")=Request.Form("quantity")
    rsadd1.update
    
    set rsadd1 = nothing
    success=true
    rsadd1.close
    else
    Duplicate=true
    rsadd1.close
    end if
    
    
    
    set rsadd = nothing
    success=true
    
    else
    Duplicate=true
    
    end if 
    rsadd.close
    
    end if
    %>
    Thanks in advance.
    Last edited by Lafinboy; September 29th, 2007 at 04:12 AM. Reason: Added code tags
  2. #2
  3. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2007
    Posts
    12
    Rep Power
    0
    help
  4. #3
  5. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
  6. #4
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2007
    Posts
    12
    Rep Power
    0
    rsadd1("Order_Id")=Request.Form("Order_Id")

    In this line it gives error
  8. #5
  9. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2925
    probably that field is numeric - have such code:
    Code:
    rsadd1("Order_Id") = CLng(Request.Form("Order_Id"))
  10. #6
  11. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Mar 2006
    Location
    South Wales
    Posts
    3,674
    Rep Power
    2047
    I don't use Access but when I use SQL Server I always set up the ID fields as ID fields so that they increment automatically - I think the Access equivalent is AutoNumber.

    If you set your table up like this it means that you don't have to worry about the user entering an ID in the wrong format, leaving it blank, or entering a number that already exists in the database.

    Comments on this post

    • Shadow Wizard agrees : yep - this might be the case too..

Similar Threads

  1. I am a beginner for ASP programming
    By Thamizhinpan in forum ASP Development
    Replies: 1
    Last Post: January 10th, 2007, 07:15 AM
  2. Beginner to ASP
    By Humaira in forum ASP Development
    Replies: 3
    Last Post: November 10th, 2005, 07:18 PM
  3. Beginner and uploading file to server coding
    By ukdave in forum .NET Development
    Replies: 2
    Last Post: February 26th, 2005, 01:39 PM
  4. Beginner DataBind() Problem...
    By Currie in forum .NET Development
    Replies: 1
    Last Post: November 24th, 2004, 03:45 PM
  5. Please help a beginner in ADO/ASP.Net.
    By Patiya in forum ASP Development
    Replies: 3
    Last Post: June 16th, 2004, 09:36 AM

IMN logo majestic logo threadwatch logo seochat tools logo