473,320 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Returning value from Like statement in SQL server 2008 to vb.net

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
Expand|Select|Wrap|Line Numbers
  1. cmd = New SqlCommand
  2.         cmd.CommandText = "sp_TransData"
  3.         cmd.CommandType = CommandType.StoredProcedure
  4.         cmd.Parameters.Add("@unamex",SqlDbType.VarChar,15)
  5.         cmd.Parameters.Add("@Username",SqlDbType.VarChar, 15)
  6.         cmd.Parameters("@unamex").Value = txt_User.Text
  7.         cmd.Parameters("@Username").Direction = ParameterDirection.Output
  8.  
  9.         Call startCon()
  10.         cmd.Connection = conData
  11.         cmd.ExecuteNonQuery()
  12.  tempvalue(0) =(cmd.Parameters("@Username").Value.ToString)
  13.  
  14. MsgBox("" + tempvalue(0))
  15.  
on my stored proc
Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[sp_TransData] 
  2. @unamex varchar(15), @Username varchar(15) output
  3.  
  4. AS
  5. set nocount on;
  6.  
  7. BEGIN
  8.  
  9. sets from
  10.  
  11. Select  @Username = Username from tbl_UserPro where Username like @unamex
  12.  
  13. END 
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
Expand|Select|Wrap|Line Numbers
  1.  SELECT [Username] FROM [dbQuines].[dbo].[tbl_UserPro] WHERE Username like '%a%' 
and it works.

I'm not really sure what i'm doing wrong here. I need guidance. Thanks in advance.
Jul 18 '10 #1
2 3135
I almost forgot to mention that tbl_UserPro on my stored procedure where i get all my data is not really a table but i created it from "Views" i'm not really sure if that helps, but i'm looking on it.
Jul 18 '10 #2
I just added this line on my stored proc and it worked wonderfully.

SELECT @unamex = RTRIM(@unamex) + '%'
Jul 18 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Chris J | last post by:
Hi all, I'm posting as a follow-up on this thread: http://groups.google.co.uk/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/25781f7b1d987306/490ef079b658c57a ....I've not...
1
by: =?Utf-8?B?S2luZXRpYyBKdW1wIEFwcGxpZmUgZm9yIC5ORVQg | last post by:
Do want to attend the Microsoft SQL Server 2008 and Visual Studio 2008 sessions at your home PC?. Yes now it is possible. Microsoft has scheduled a Webcasts for you on SQL Server 2008 and Visual...
1
by: =?Utf-8?B?bWFzYWtpeQ==?= | last post by:
Hello, I'm trying to develop 32-bit Windows Native C/C++ application using Visual Studio 2008, on 64-bit Windows Server 2008. Q1. Is it possible to develop 32-bit C/C++ application using VS 2008...
1
by: Ken Fine | last post by:
I have set up Microsoft Search Server 2008 Express. I want to know how I can query against it and return results in a form that can be bound to ASP.NET controls like ListViews. If there's simply...
1
by: Chris O'C | last post by:
See: http://blogs.zdnet.com/microsoft/?p=1519 "Microsoft officials announced at TechEd South Africa on August 6 that SQL Server 2008 has been released to manufacturing. "Microsoft officials...
1
by: =?Utf-8?B?QW50amU=?= | last post by:
I need product keys for Terminal Server Windows Server 2008 access (CALs) under MSDN - TSLM Service said they cannot provide product keys for the access.
6
by: AAaron123 | last post by:
I need to move a database from sql server 2008 to sql express 2008. Will backing up the sql server 2008 database to a file and then using that file to restore to sql express 2008 work? I don't...
2
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts:...
1
by: BobLewiston | last post by:
I installed SQL Server 2008 Express, basic edition (SQLEXPR32_x86_ENU_Bootstrapper.exe, version 9.0.30729.1) without any problem. Then I attempted to install AdventureWorks Sample Databases for...
0
by: LitaOsiris | last post by:
Hi everyone, I'm doing a website in JSP. I'm using Tomcat 6 and have gotten the site talking to the backend file. However, when I go to add in a database connection, I have problems. This is my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.