Problem writing to SQL database--please help.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > IIS server support > IIS ASP > Problem writing to SQL database--please help.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Problem writing to SQL database--please help.  
Barnes


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-30-04 11:01 PM

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 with
out errors and goes to the redirect page but the data doesn't populate the S
QL database. Instead, refer
rs 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!!






[ Post a follow-up to this message ]



    Re: Problem writing to SQL database--please help.  
Ray at


Report This Message To A Moderator Edit/Delete Message


 
07-01-04 01:52 AM

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" <Barnes@discussions.microsoft.com> wrote in message
news:314421BD-C0F4-4070-8E3D-64885CFB05EC@microsoft.com...
> 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!!
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:31 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register