?
Solved

SQL Wildcard and @variable not working

Posted on 2004-08-10
1
Medium Priority
?
517 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
boulder_bum earned 1000 total points
ID: 11769124
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

719 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