|
-
Oct 24th, 2005, 08:25 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] what is wrong with this syntax
Dim sqlcmd As New SqlCommand("sprInsertUser", oSQLConn1)
sqlcmd.Parameters.Add("@fname", SqlDbType.Char).Value = txtFname.Text
sqlcmd.Parameters.Add("@town", SqlDbType.Char).Value = txttown.Text
sqlcmd.Parameters.Add("@carreg", SqlDbType.Char).Value = txtcarreg.Text
oSQLConn1.Open()
sqlcmd.ExecuteNonQuery()
oSQLConn1.Close()
i get the error
Incorrect syntax near 'sprInsertUser'.
it works 60% of the time, all the time.
-
Oct 24th, 2005, 08:49 AM
#2
Re: what is wrong with this syntax
Do you get this on the line ExecuteNonQuery?
Can you post the SP you are using...well at least the DECLARE bits from the top.
The param types must match the SP params exactly.
Woof
-
Oct 24th, 2005, 08:56 AM
#3
Thread Starter
Fanatic Member
Re: what is wrong with this syntax
ive changed it to this
VB Code:
oSQLConn1.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=StoreProc;" & _
"Integrated Security=SSPI"
strSql = "EXECUTE sprInsertUser"
Dim sqlcmd As New SqlCommand(strSql, oSQLConn1)
sqlcmd.Parameters.Add("@fname", SqlDbType.Char).Value = txtFname.Text
sqlcmd.Parameters.Add("@town", SqlDbType.Char).Value = txttown.Text
sqlcmd.Parameters.Add("@carreg", SqlDbType.Char).Value = txtcarreg.Text
oSQLConn1.Open()
sqlcmd.ExecuteNonQuery()
oSQLConn1.Close()
but now im on this error
Procedure 'sprInsertUser' expects parameter '@fname', which was not supplied.
the SP is
Code:
CREATE PROCEDURE sprInsertUser
(
@fname char(10),
@town char(10),
@carreg char(10)
)
AS
INSERT INTO tbUser
(fname, town, carreg)
VALUES
(@fname, @town, @carreg)
GO
it works 60% of the time, all the time.
-
Oct 24th, 2005, 02:20 PM
#4
Re: what is wrong with this syntax
Change the source SQL from
EXECUTE sprInsertUser
to
EXECUTE sprInsertUser @fname, @town, @carreg
And preserve all the rest of the code you have
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 25th, 2005, 03:53 AM
#5
Thread Starter
Fanatic Member
Re: what is wrong with this syntax
thats the job,
i spent all day yesterday trying to get that to work, lol
in this morning checked the thread and 2 seconds job done,
THANKS
do you know of any good books for stored procedures and asp.net,
i think i should get one
it works 60% of the time, all the time.
-
Oct 25th, 2005, 09:13 AM
#6
Lively Member
Re: [RESOLVED] what is wrong with this syntax
You could also set the commandType to StoredProcedure:
VB Code:
Dim sqlcmd As New SqlCommand("sprInsertUser", oSQLConn1)
sqlcmd.CommandType = CommandType.StoredProcedure
'ect....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|