New Message on dotNET User Group Hyd

Passing Parrameters

Reply
  Reply to Sender   Recommend Message 3 in Discussion
From: raja bolisetty

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

 

New Message on dotNET User Group Hyd

 

Passing Parrameters

Reply

 

Reply to Sender   Recommend

Message 1 in Discussion

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.


View other groups in this category.

Click here!
Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to