Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ASP & SQL Problem

Im trying to post info into an access database using sql commands. The code I have puts info into one table but not the other.

Here are the two pages:

Page1:


First Name:
Middle:
Last Name:
Address1:
Address2:
City:
State:
Zip:
Product:
Widget1 $150,000.00
Widget2 $270,000.00
Widget3 $1,500,000.00

Quantity:
Time:
Size="20" />








Page2(called by Page1):



<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("Final.mdb"))
sql="INSERT INTO Customers (FirstName, MI, LastName, Address1, Address2,"
sql=sql & "City, State, Zip)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("FirstName") & "',"
sql=sql & "'" & Request.Form("MI") & "',"
sql=sql & "'" & Request.Form("LastName") & "',"
sql=sql & "'" & Request.Form("Address1") & "',"
sql=sql & "'" & Request.Form("Address2") & "',"
sql=sql & "'" & Request.Form("City") & "',"
sql=sql & "'" & Request.Form("State") & "',"
sql=sql & "'" & Request.Form("Zip") & "')"
sqll="INSERT INTO Orders (DateTime, FirstName, LastName,"
sqll=sqll & "ProductName, Quantity)"
sqll=sqll & " VALUES "
sqll=sqll & "('" & Request.Form("DateTime") & "',"
sqll=sqll & "'" & Request.Form("FirstName") & "',"
sqll=sqll & "'" & Request.Form("LastName") & "',"
sqll=sqll & "'" & Request.Form("ProductName") & "'"
sqll=sqll & "'" & Request.Form("Quantity") & "')"
conn.Execute sql , sqll, recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("

" & recaffected & " record added

")
end if





conn.Close
%>







Any help is appreciated!

Comments

  • FlakesFlakes Member Posts: 642
    You have to call two executes :
    [code]
    conn.Execute sql
    conn.Execute sqll
    [/code]

    You could also try this, i am not sure if it will work..
    [code]
    sql=sql&";"&sqll
    conn.Execute sql
    [/code]


  • punit kumar rapunit kumar ra Member Posts: 2
    : Im trying to post info into an access database using sql commands. The code I have puts info into one table but not the other.
    :
    : Here are the two pages:
    :
    : Page1:
    :
    :
    :
    :
    :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    :
    :
    First Name:
    Middle:
    Last Name:
    Address1:
    Address2:
    City:
    State:
    Zip:
    Product:
    : Widget1 $150,000.00
    : Widget2 $270,000.00
    : Widget3 $1,500,000.00
    :
    :
    Quantity:
    Time:
    : Size="20" />
    :
    :


    :
    :
    :
    :
    :
    :
    : Page2(called by Page1):
    :
    :
    :
    : <%
    : set conn=Server.CreateObject("ADODB.Connection")
    : conn.Provider="Microsoft.Jet.OLEDB.4.0"
    : conn.Open(Server.Mappath("Final.mdb"))
    : sql="INSERT INTO Customers (FirstName, MI, LastName, Address1, Address2,"
    : sql=sql & "City, State, Zip)"
    : sql=sql & " VALUES "
    : sql=sql & "('" & Request.Form("FirstName") & "',"
    : sql=sql & "'" & Request.Form("MI") & "',"
    : sql=sql & "'" & Request.Form("LastName") & "',"
    : sql=sql & "'" & Request.Form("Address1") & "',"
    : sql=sql & "'" & Request.Form("Address2") & "',"
    : sql=sql & "'" & Request.Form("City") & "',"
    : sql=sql & "'" & Request.Form("State") & "',"
    : sql=sql & "'" & Request.Form("Zip") & "')"
    : sqll="INSERT INTO Orders (DateTime, FirstName, LastName,"
    : sqll=sqll & "ProductName, Quantity)"
    : sqll=sqll & " VALUES "
    : sqll=sqll & "('" & Request.Form("DateTime") & "',"
    : sqll=sqll & "'" & Request.Form("FirstName") & "',"
    : sqll=sqll & "'" & Request.Form("LastName") & "',"
    : sqll=sqll & "'" & Request.Form("ProductName") & "'"
    : sqll=sqll & "'" & Request.Form("Quantity") & "')"
    : conn.Execute sql , sqll, recaffected
    : if err<>0 then
    : Response.Write("No update permissions!")
    : else
    : Response.Write("

    " & recaffected & " record added

    ")
    : end if
    :
    :
    :
    :
    :
    : conn.Close
    : %>
    :
    :
    :
    :
    :
    :
    :
    : Any help is appreciated!
    :

  • DevayaniDevayani Member Posts: 9
    hi,
    since u are usng two sql statements,u have to use
    conn.execute sql
    conn.execute sql1

    try dis out....

    all the best.



    : : Im trying to post info into an access database using sql commands. The code I have puts info into one table but not the other.
    : :
    : : Here are the two pages:
    : :
    : : Page1:
    : :
    : :
    : :
    : :
    : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : : : : : : : :
    : :
    : :
    First Name:
    Middle:
    Last Name:
    Address1:
    Address2:
    City:
    State:
    Zip:
    Product:
    : : Widget1 $150,000.00
    : : Widget2 $270,000.00
    : : Widget3 $1,500,000.00
    : :
    : :
    Quantity:
    Time:
    : : Size="20" />
    : :
    : :


    : :
    : :
    : :
    : :
    : :
    : :
    : : Page2(called by Page1):
    : :
    : :
    : :
    : : <%
    : : set conn=Server.CreateObject("ADODB.Connection")
    : : conn.Provider="Microsoft.Jet.OLEDB.4.0"
    : : conn.Open(Server.Mappath("Final.mdb"))
    : : sql="INSERT INTO Customers (FirstName, MI, LastName, Address1, Address2,"
    : : sql=sql & "City, State, Zip)"
    : : sql=sql & " VALUES "
    : : sql=sql & "('" & Request.Form("FirstName") & "',"
    : : sql=sql & "'" & Request.Form("MI") & "',"
    : : sql=sql & "'" & Request.Form("LastName") & "',"
    : : sql=sql & "'" & Request.Form("Address1") & "',"
    : : sql=sql & "'" & Request.Form("Address2") & "',"
    : : sql=sql & "'" & Request.Form("City") & "',"
    : : sql=sql & "'" & Request.Form("State") & "',"
    : : sql=sql & "'" & Request.Form("Zip") & "')"
    : : sqll="INSERT INTO Orders (DateTime, FirstName, LastName,"
    : : sqll=sqll & "ProductName, Quantity)"
    : : sqll=sqll & " VALUES "
    : : sqll=sqll & "('" & Request.Form("DateTime") & "',"
    : : sqll=sqll & "'" & Request.Form("FirstName") & "',"
    : : sqll=sqll & "'" & Request.Form("LastName") & "',"
    : : sqll=sqll & "'" & Request.Form("ProductName") & "'"
    : : sqll=sqll & "'" & Request.Form("Quantity") & "')"
    : : conn.Execute sql , sqll, recaffected
    : : if err<>0 then
    : : Response.Write("No update permissions!")
    : : else
    : : Response.Write("

    " & recaffected & " record added

    ")
    : : end if
    : :
    : :
    : :
    : :
    : :
    : : conn.Close
    : : %>
    : :
    : :
    : :
    : :
    : :
    : :
    : :
    : : Any help is appreciated!
    : :
    :
    :

Sign In or Register to comment.