Problem writing to SQL database--please help.

Discussion in 'ASP General' started by Barnes, Jul 1, 2004.

  1. Barnes

    Barnes Guest

    I have an asp form that sends data to a redirect page with SQL using JScript. There is a function that I'm using called replace(). The form submits without errors and goes to the redirect page but the data doesn't populate the SQL database. Instead, referrs to the last key ID.
    ------------------------
    <%
    function replace(string)
    {
    var pattern = /\'/g;
    var newString = string.replace(pattern, "''");

    // Create a database connection.

    //Database.Open ("dsn=INTRANET");

    // Create a recordset of all information in this table.

    // Construct the SQL Query
    strSQL = "INSERT INTO " + ...

    DirectoryRecordSet.Open (strSQL, Database);

    return newString

    }

    %>

    ------------------------------

    Please help!

    Thank you!!
     
    Barnes, Jul 1, 2004
    #1
    1. Advertising

  2. Barnes

    Ray at Guest

    A few tips:

    Put a Response.end in your code before the redirect, so in the event of an
    error, you see it.

    Your replace function is fine.

    DSNs use an ODBC connection, which is old technlogy. You're best off using
    an OLEDB connection with a DSNless connection string.
    http://www.aspfaq.com/show.asp?id=2126

    When you insert data into a database, there is no need to create a recordset
    object. Just execute your SQL command.
    http://www.aspfaq.com/show.asp?id=2191

    Ray at home


    "Barnes" <> wrote in message
    news:...
    > I have an asp form that sends data to a redirect page with SQL using

    JScript. There is a function that I'm using called replace(). The form
    submits without errors and goes to the redirect page but the data doesn't
    populate the SQL database. Instead, referrs to the last key ID.
    > ------------------------
    > <%
    > function replace(string)
    > {
    > var pattern = /\'/g;
    > var newString = string.replace(pattern, "''");
    >
    > // Create a database connection.
    >
    > //Database.Open ("dsn=INTRANET");
    >
    > // Create a recordset of all information in this table.
    >
    > // Construct the SQL Query
    > strSQL = "INSERT INTO " + ...
    >
    > DirectoryRecordSet.Open (strSQL, Database);
    >
    > return newString
    >
    > }
    >
    > %>
    >
    > ------------------------------
    >
    > Please help!
    >
    > Thank you!!
    >
     
    Ray at, Jul 1, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul
    Replies:
    1
    Views:
    364
    Miha Markic
    Jan 15, 2004
  2. KK
    Replies:
    2
    Views:
    668
    Big Brian
    Oct 14, 2003
  3. Glen Buell
    Replies:
    5
    Views:
    1,067
    Billy Biro
    Feb 6, 2007
  4. ecoolone
    Replies:
    0
    Views:
    790
    ecoolone
    Jan 3, 2008
  5. cooldv
    Replies:
    3
    Views:
    285
    WIlliam Morris
    Oct 6, 2003
Loading...

Share This Page