In
your code line Dim p1 As New SqlParameter(), you have not passed the parameter
name which is there in SProc
For example…
Dim arrParams(3) As SqlParameter
arrParams(0) = New SqlParameter("RETURN_VALUE",
SqlDbType.Int)
arrParams(0).Direction =
ParameterDirection.ReturnValue
arrParams(1) = New SqlParameter("@strUserID",
SqlDbType.VarChar, 60)
arrParams(1).Value = UserID
arrParams(2) = New SqlParameter("@intOrganizationId",
SqlDbType.Int)
arrParams(2).Value = OrganizationId
arrParams(3) = New SqlParameter("@errMsg",
SqlDbType.VarChar, 200)
arrParams(3).Direction =
ParameterDirection.Output
cheers
Raja
-----Original Message-----
From: rameshpgs
[mailto:[EMAIL PROTECTED]
Sent: Wednesday,
April 14, 2004 5:05 PM
To: dotNET User Group Hyd
Subject: Passing Parrameters
Passing Parrameters
|
Reply
|
|
|
From: rameshpgs
|
|
Error showing Parrameter one is not Parrameter to storeprocedure
name(sp_login).
My code is below
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
'If txtUserId.Text = "ramesh" And txtPwd.Text = "a"
Then
' Response.Redirect("reg1.aspx")
'Else
' Response.Redirect("homepage.aspx")
'End If
Try
Dim sp_login As String
Dim cmd As New SqlCommand()
Dim p1 As New SqlParameter()
Dim p2 As New SqlParameter()
Dim p3 As New SqlParameter()
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_login"
p1.SqlDbType = SqlDbType.NVarChar
p1.Direction = ParameterDirection.Input
p1.Value = Trim(txtUserId.Text)
p2.SqlDbType = SqlDbType.NVarChar
p2.Direction = ParameterDirection.Input
p2.Value = Trim(txtPwd.Text)
p3.SqlDbType = SqlDbType.Int
p3.Direction = ParameterDirection.Output
cmd.Parameters.Add(p1)
cmd.Parameters.Add(p2)
cmd.Parameters.Add(p3)
cmd.ExecuteNonQuery()
If p3.Value = 1 Then
Server.Transfer("reg1.aspx")
Else
Response.Write("Invalid Login")
End If
Catch ee As SqlException
Response.Write(ee.Message)
Finally
con.Close()
End Try
End Sub
==========Stored Procedure===============
create proc sp_Login @uid varchar(30),@pwd Varchar(20),@Chk int output
as
begin
declare cr1 cursor for
select distinct username,password from Login where [EMAIL PROTECTED] and
[EMAIL PROTECTED]
open cr1
fetch next from cr1 into @Uid,@pwd
-- if cursor_status('Variable','@cr1')<=0
while @@fetch_status=0
begin
--set @chk=0
set @chk=1
fetch next from cr1 into @Uid,@pwd
end
close cr1
deallocate cr1
--print @chk
end
===============================================================================
declare @dec int
exec sp_login 'ram','a',@dec output
print @dec
insert into Login values('ram','a')
pl'e tell me where went wrong
thanks in advance
Ramesh
|
|
View other groups in this
category.