Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 10:59 AM
Guest
 
Posts: n/a
Default insert record using stored proc returns no error but doesn't inserd record

Hi

I am using SQL server 7.0 and here is my code:

Dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.open "websql"

If conn.state=adStateOpen then
Response.Write("ConnMade : " & conn.state
& "<BR>")
Response.flush
else
Response.Write("not ConnMade : " &
conn.state & "<BR>")
end if
'response.write sql
conn.execute("Insert_Emailseller" &_
" @fname='" & fname & "'," &_
" @lname='" & lname & "'," &_
" @dphone='" & dphone & "'," &_
" @ephone='" & ephone & "'," &_
" @email='" & email & "'," &_
" @comments='" & comments & "'," &_
" @chktrade='" & chktrade & "'," &_
" @chkfinance='" & chkfinance & "'," &_
" @ctime='" & ctime & "'," &_
" @prom='" & prom & "'," &_
" @dealerid='" & dealerid & "'," &_
" @vin='" & vin & "'," &_
" @dateandtime=" & dateandtime)
'conn.ExecuteComplete(sql)
'Response.write("Record inserted. ID number was <b>" &
rs(0) & "</b>.")
'rs.close: set rs = nothing
conn.close: set conn = nothing

and my stored procedure is:
CREATE PROCEDURE dbo.Insert_Emailseller

@fname varchar (50) ,
@lname varchar (50) ,
@dphone int ,
@ephone int ,
@email varchar (50) ,
@comments text ,
@chktrade bit ,
@chkfinance bit ,
@ctime char (10) ,
@prom tinyint ,
@dealerid char (10) ,
@vin varchar (18) ,
@dateandtime datetime
AS
BEGIN
SET NOCOUNT ON
DECLARE @new_emailseller INT
INSERT caremail_leads
(
fname ,
lname ,
dphone ,
ephone ,
email ,
comments ,
chktrade ,
chkfinance ,
ctime ,
prom ,
dealerid ,
vin ,
dateandtime
)
VALUES
(
@fname ,
@lname ,
@dphone ,
@ephone ,
@email ,
@comments ,
@chktrade ,
@chkfinance ,
@ctime ,
@prom ,
@dealerid ,
@vin ,
@dateandtime
)
SELECT @new_emailseller = @@IDENTITY
SELECT new_emailseller = @new_emailseller
END


  #2  
Old July 19th, 2005, 11:00 AM
Alex G
Guest
 
Posts: n/a
Default Re: insert record using stored proc returns no error but doesn't inserd record

Shouldn't the stored procedure be using INSERT INTO not just INSERT ??

<anonymous@discussions.microsoft.com> wrote in message news:<046001c3d622$e9fc6410$a101280a@phx.gbl>...[color=blue]
> Hi
>
> I am using SQL server 7.0 and here is my code:
>
> Dim conn
> set conn = Server.CreateObject("ADODB.Connection")
> conn.open "websql"
>
> If conn.state=adStateOpen then
> Response.Write("ConnMade : " & conn.state
> & "<BR>")
> Response.flush
> else
> Response.Write("not ConnMade : " &
> conn.state & "<BR>")
> end if
> 'response.write sql
> conn.execute("Insert_Emailseller" &_
> " @fname='" & fname & "'," &_
> " @lname='" & lname & "'," &_
> " @dphone='" & dphone & "'," &_
> " @ephone='" & ephone & "'," &_
> " @email='" & email & "'," &_
> " @comments='" & comments & "'," &_
> " @chktrade='" & chktrade & "'," &_
> " @chkfinance='" & chkfinance & "'," &_
> " @ctime='" & ctime & "'," &_
> " @prom='" & prom & "'," &_
> " @dealerid='" & dealerid & "'," &_
> " @vin='" & vin & "'," &_
> " @dateandtime=" & dateandtime)
> 'conn.ExecuteComplete(sql)
> 'Response.write("Record inserted. ID number was <b>" &
> rs(0) & "</b>.")
> 'rs.close: set rs = nothing
> conn.close: set conn = nothing
>
> and my stored procedure is:
> CREATE PROCEDURE dbo.Insert_Emailseller
>
> @fname varchar (50) ,
> @lname varchar (50) ,
> @dphone int ,
> @ephone int ,
> @email varchar (50) ,
> @comments text ,
> @chktrade bit ,
> @chkfinance bit ,
> @ctime char (10) ,
> @prom tinyint ,
> @dealerid char (10) ,
> @vin varchar (18) ,
> @dateandtime datetime
> AS
> BEGIN
> SET NOCOUNT ON
> DECLARE @new_emailseller INT
> INSERT caremail_leads
> (
> fname ,
> lname ,
> dphone ,
> ephone ,
> email ,
> comments ,
> chktrade ,
> chkfinance ,
> ctime ,
> prom ,
> dealerid ,
> vin ,
> dateandtime
> )
> VALUES
> (
> @fname ,
> @lname ,
> @dphone ,
> @ephone ,
> @email ,
> @comments ,
> @chktrade ,
> @chkfinance ,
> @ctime ,
> @prom ,
> @dealerid ,
> @vin ,
> @dateandtime
> )
> SELECT @new_emailseller = @@IDENTITY
> SELECT new_emailseller = @new_emailseller
> END[/color]
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles