Solved

SQL Wildcard and @variable not working

Posted on 2004-08-10
1
504 Views
Last Modified: 2012-05-05
The wildcard is not working correctly with the variable for some reason.
If I put 2101% directly in the search string it works fine.
If I replace the @addrinfo.value = "2101" it doesn't work? or ="2101%"
I have also tried changing the @addrinfo datatype and no go.
I don't want to make a stored procedure if I don't have too.

Thanks so much for any help.

Dim viewall As New DataSet
        Dim getnumber = Split(Add_Address.Text, " ", -1, 1)
        Add_Site.Text = getnumber(0)
        Dim DetailStr As String = "SELECT HPLocID, Site, Mapsco, ServiceAddr, SiteType, City, Zip, Newmain, NewFax FROM Locations where ServiceAddr LIKE '@addrinfo%'"
        Dim cmd As New SqlCommand(DetailStr, MyConnection)
        Dim satlist As New SqlDataAdapter(cmd)

        cmd.Parameters.Add("@addrinfo", SqlDbType.NVarChar, 10)
        cmd.Parameters("@addrinfo").Value = getnumber(0)
        cmd.Parameters("@addrinfo").Direction = ParameterDirection.Input
        satlist.Fill(viewall, "Locations")
0
Comment
Question by:j_tipps
1 Comment
 
LVL 8

Accepted Solution

by:
boulder_bum earned 250 total points
Comment Utility
It's literally trying to find '@addrinfo....' so it will find "@addrinfoPlus Extra Text", but not what you want it to.

Try " LIKE @addrinfo + '%' "
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now