Results 1 to 4 of 4

Thread: Insert into??? Why I can't?

  1. #1
    Alex Guest

    Insert into??? Why I can't?

    I'm using it, and don't works, why???

    connection.Execute("insert into pedidos (id_pedido, id_articulo, id_proveedor, precio, cantidad, nombre, apellidos, direccion1, direccion2, cp, ciudad, provincia, telefono, mail, banco, cc_entidad, cc_oficina, cc_dc, cc_cuenta) values (" & Session.SessionID & ", " & request.form("id&#34 & ", " & request.form("proveedor&#34 & ", " & request.form("preciopart&#34 & ", " & request.form("cantidad&#34 & ", " & request.form("nombre&#34 & ", " & request.form("apellidos&#34 & ", " & request.form("direccion&#34 & ", " & request.form("direccion2&#34 & ", " & request.form("cp&#34 & ", " & request.form("ciudad&#34 & ", " & request.form("provincia&#34 & ", " & request.form("tel&#34 & ", " & request.form("mail&#34 & ", " & request.form("banco&#34 & ", " & request.form("entidad&#34 & ", " & request.form("oficina&#34 & ", " & request.form("dc&#34 & ", " & request.form("cc&#34 & &#34&#34

  2. #2
    MAK Guest

    Insert into??? Why I can't? (reply)

    what was the error?

    Did u try testing it by copying all these responses to different variables before doing it?

    -MAK


    ------------
    Alex at 10/23/00 2:53:20 PM

    I'm using it, and don't works, why???

    connection.Execute("insert into pedidos (id_pedido, id_articulo, id_proveedor, precio, cantidad, nombre, apellidos, direccion1, direccion2, cp, ciudad, provincia, telefono, mail, banco, cc_entidad, cc_oficina, cc_dc, cc_cuenta) values (" & Session.SessionID & ", " & request.form("id&#34 & ", " & request.form("proveedor&#34 & ", " & request.form("preciopart&#34 & ", " & request.form("cantidad&#34 & ", " & request.form("nombre&#34 & ", " & request.form("apellidos&#34 & ", " & request.form("direccion&#34 & ", " & request.form("direccion2&#34 & ", " & request.form("cp&#34 & ", " & request.form("ciudad&#34 & ", " & request.form("provincia&#34 & ", " & request.form("tel&#34 & ", " & request.form("mail&#34 & ", " & request.form("banco&#34 & ", " & request.form("entidad&#34 & ", " & request.form("oficina&#34 & ", " & request.form("dc&#34 & ", " & request.form("cc&#34 & &#34&#34

  3. #3
    Keith Rome Guest

    Insert into??? Why I can't? (reply)

    This is going to sound rather hostile, but just do yourself a favor and create a stored procedure or at least a parameterized query for this. You are totally ignoring the fact that string values must be enclosed in quotes, and if any of those ASP request form variables are not set, you will simply cause the insert to fail and display a nasty error to the browser.

    1. Create a stored procedure with parameters for the fields to be inserted.
    2. Use a Command object and set the command string to the name of the stored proc.
    3. Set the Connection property of the Command to the Command object you aer trying to exec the raw sql on.
    3. Add your parameters explicitly, or if you are lazy just ignore this step and call Refresh on the Parameters.
    4. Set the parameter values from the Request form variables.
    5. Execute the Command object.

    It is very bad practice to issue dynamic SQL statements like that to a database server. Hard to maintain, hard to debug, hard to scale, and a real dog on performance.


    ------------
    Alex at 10/23/00 2:53:20 PM

    I'm using it, and don't works, why???

    connection.Execute("insert into pedidos (id_pedido, id_articulo, id_proveedor, precio, cantidad, nombre, apellidos, direccion1, direccion2, cp, ciudad, provincia, telefono, mail, banco, cc_entidad, cc_oficina, cc_dc, cc_cuenta) values (" & Session.SessionID & ", " & request.form("id&#34 & ", " & request.form("proveedor&#34 & ", " & request.form("preciopart&#34 & ", " & request.form("cantidad&#34 & ", " & request.form("nombre&#34 & ", " & request.form("apellidos&#34 & ", " & request.form("direccion&#34 & ", " & request.form("direccion2&#34 & ", " & request.form("cp&#34 & ", " & request.form("ciudad&#34 & ", " & request.form("provincia&#34 & ", " & request.form("tel&#34 & ", " & request.form("mail&#34 & ", " & request.form("banco&#34 & ", " & request.form("entidad&#34 & ", " & request.form("oficina&#34 & ", " & request.form("dc&#34 & ", " & request.form("cc&#34 & &#34&#34

  4. #4
    Guest

    Insert into??? Why I can't? (reply)

    The error is:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ','.

    /pedido_run.asp, line 178

    and the sentences is:
    connection.Execute("insert into pedidos (id_pedido, id_articulo, id_proveedor, precio, cantidad, nombre, apellidos, direccion1, direccion2, cp, ciudad, provincia, telefono, mail, banco, cc_entidad, cc_oficina, cc_dc, cc_cuenta, nacimiento) values (" & Session.SessionID & ", " & id & ", " & proveedor & ", '" & preciopart & "', " & cantidad & ", '" & nombre & "', '" & rapellidos & "', " & direccion & ", '" & direccion2 & "', " & cp & ", '" & ciudad & "', '" & provincia & "', '" & telefono & "', '" & mail & "', '" & banco & "', " & entidad & ", " & oficina & ", " & dc & ", " & cc & ", getdate())&#34

    ------------
    MAK at 10/23/00 3:08:43 PM

    what was the error?

    Did u try testing it by copying all these responses to different variables before doing it?

    -MAK


    ------------
    Alex at 10/23/00 2:53:20 PM

    I'm using it, and don't works, why???

    connection.Execute("insert into pedidos (id_pedido, id_articulo, id_proveedor, precio, cantidad, nombre, apellidos, direccion1, direccion2, cp, ciudad, provincia, telefono, mail, banco, cc_entidad, cc_oficina, cc_dc, cc_cuenta) values (" & Session.SessionID & ", " & request.form("id&#34 & ", " & request.form("proveedor&#34 & ", " & request.form("preciopart&#34 & ", " & request.form("cantidad&#34 & ", " & request.form("nombre&#34 & ", " & request.form("apellidos&#34 & ", " & request.form("direccion&#34 & ", " & request.form("direccion2&#34 & ", " & request.form("cp&#34 & ", " & request.form("ciudad&#34 & ", " & request.form("provincia&#34 & ", " & request.form("tel&#34 & ", " & request.form("mail&#34 & ", " & request.form("banco&#34 & ", " & request.form("entidad&#34 & ", " & request.form("oficina&#34 & ", " & request.form("dc&#34 & ", " & request.form("cc&#34 & &#34&#34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •