469,303 Members | 1,910 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,303 developers. It's quick & easy.

Problem writing to SQL database--please help.

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!!

Jul 19 '05 #1
1 1254
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" <Ba****@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.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!!

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Gary Hughes | last post: by
reply views Thread by Sukh | last post: by
2 posts views Thread by Eduardo Biano | last post: by
19 posts views Thread by rmr531 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.