Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ASP & Stored Procedures to Insert new Records

Status
Not open for further replies.

Rexolio

Technical User
Joined
Aug 29, 2001
Messages
230
I have 2 books...SQL for Dummies and Active Server Pages Bible..so far both are great. However, I have a problem with inserting new records from my web site via a registration form to a table in my SQL database. I use a similar ADO insert script for another part of my site, and it inserts very quickly. But this one has a problem and seems to take between 10 and 30 seconds to insert. I've tried everything and used this site to try and figure out what it is. I can't isolate it to any one thing.

My ASP Bible says to create a stored procedure and then use it from my web site to utilize it. SQL for Dummies doesn't tell me anything and the ASP Bible book says to refer to SQL documentation.

My question: can someone give me an example of a script, include connection and close, that will insert from a web site form to a SQL database via a stored procedure? I have the stored procedure created already. I've tried creating a script...but it keeps saying that I'm not using the right parameters (@FirstName_1)...the actual form field name and table field name is simply FirstName. The name @FirstName_1 was the name given my the Create Stored Procedure Wizard.

Thanks in advance!
 
What is the exact error message?

These are the essential pieces to insert data from an HTML form into a SQL Server database using ADODB and ASP with the JScript scripting language.


The page with the form --
Code:
<HTML>
etc.
   <FORM METHOD=&quot;post&quot; etc.>
      <INPUT TYPE=&quot;text&quot; NAME=&quot;FirstName&quot;>
      etc.
   </FORM>
</HTML>



The page with the script to insert data from the form

Code:
<%
var fn = Request.Form(&quot;FirstName&quot;);

var cmdAddStuff = Server.CreateObject(&quot;ADODB.Command&quot;);
etc.
cmdAddStuff.CommandText = &quot;{CALL proc_add_stuff('&quot; + fn + &quot;')}&quot;;
cmdAddStuff.Execute();
etc.
%>


The stored procedure in SQL Server --

CREATE PROCEDURE[proc_add_stuff](
   @first_name VARCHAR(20)
)

INSERT INTO myTable (FirstName)
VALUES (@first_name)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top