I'm in a bit of a pickle here. I need to pass the variable @uname which gets a value from a text box to a statement on one of my stored procedures in SQL server and return an output on my form.
Here is the code:
in .net
on my stored proc
What happens is that it returns a NULL VALUE. ""
I've tried a couple of things like, running the "like statement" on SQL server having
and it works.
I'm not really sure what i'm doing wrong here. I need guidance. Thanks in advance.
Here is the code:
in .net
Code:
cmd = New SqlCommand cmd.CommandText = "sp_TransData" cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add("@unamex",SqlDbType.VarChar,15) cmd.Parameters.Add("@Username",SqlDbType.VarChar, 15) cmd.Parameters("@unamex").Value = txt_User.Text cmd.Parameters("@Username").Direction = ParameterDirection.Output Call startCon() cmd.Connection = conData cmd.ExecuteNonQuery() tempvalue(0) =(cmd.Parameters("@Username").Value.ToString) MsgBox("" + tempvalue(0))
Code:
ALTER PROCEDURE [dbo].[sp_TransData] @unamex varchar(15), @Username varchar(15) output AS set nocount on; BEGIN sets from Select @Username = Username from tbl_UserPro where Username like @unamex END
I've tried a couple of things like, running the "like statement" on SQL server having
Code:
SELECT [Username] FROM [dbQuines].[dbo].[tbl_UserPro] WHERE Username like '%a%'
I'm not really sure what i'm doing wrong here. I need guidance. Thanks in advance.
Comment