Solved

SQL Wildcard and @variable not working

Posted on 2004-08-10
1
516 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 250 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

622 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