-1

I have a form. Its data must be inserted into database (sql server 2008). I have written procedure to insert. How can i insert form data using stored procedure in classic ASP? Need some help as am new to asp and ado.

ALTER PROCEDURE INSERTVALUE 
    @COMPANY_ID INT ,
    @COMPANY_NAME VARCHAR(20),
    @SALES_REP VARCHAR (20),
    @CONTRACT_ADMIN VARCHAR (20)

AS
BEGIN
    INSERT INTO [form].[dbo].[COMPANY]
           ([COMPANY_ID]
           ,[COMPANY_NAME]
           ,[SALES_REP]
           ,[CONTRACT_ADMIN])
     VALUES (@COMPANY_ID,@COMPANY_NAME,@SALES_REP,@CONTRACT_ADMIN);
END
GO

Edit (originally and wrongly posted as answer)

I tried to execute the following code but error occurs. ADODB.Command error '800a0bb9' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. /AddForm.asp, line 15 –

set rs=Server.CreateObject("ADODB.recordset")
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cnn
sql = " SELECT * FROM COMPANY"
rs.Open sql, cnn
If Request("submit") <> "" Then 
cmd.CommandText = "INSERTVALUE"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Append cmd.CreateParameter("@COMPANY_ID",adint,adParamInput,10,Request.form("CompanyId")) 
cmd.Parameters.Append cmd.CreateParameter("@COMPANY_NAME",advarchar,adParamInput,10, Request.form("company_name"))
cmd.Parameters.Append cmd.CreateParameter("@SALES_REP",advarchar,adParamInput,10,Request.form("sales_rep")) 
cmd.Parameters.Append cmd.CreateParameter("@CONTRACT_ADMIN",advarchar,adParamInput,10,  Request.form("contract_admin"))
cmd.Execute     
End If
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252
  • 2
    For a general tutorial search the phrase "using stored procedures in classic asp". There are many examples and thorough explanations to illustrate usage. If you then have specific problems or questions come back and post them. – Dee Nov 07 '14 at 07:14
  • You want us to teach you the basic programming on the level of the documentation and / or any tutorial on the internet? Interesting approach to learn programming - not learning and asking others to learn for you. Sadly not within the site rules. – TomTom Nov 10 '14 at 08:49
  • I asked this question as i faced errors after many trials. I didn't raise this question blindly.Anyway thanks for your comment Tom. – Jeraldine Gabrielle Nov 10 '14 at 09:37
  • You should have used what you wrote in anwser in an edit of your question (I did it for you). What is *AddForm.asp, line **15*** – Serge Ballesta Nov 10 '14 at 10:29
  • AddForm is my asp file. – Jeraldine Gabrielle Nov 10 '14 at 11:00

1 Answers1

0

One possible cause of your problems and the tutorial don't tell you (or at least the ones I found didn't): if the adovbs.inc files is not found, it will give you:

ADODB.Comman error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict 
with one another.

I had to explicitly include a copy of it.

user692942
  • 16,398
  • 7
  • 76
  • 175
Alastar
  • 9
  • 1
  • Don't use `adovbs.inc` (or equivalent) instead use [METADATA to Import DLL Constants](http://stackoverflow.com/a/26776169/692942). – user692942 Nov 20 '14 at 13:49