Solved

SQL Wildcard and @variable not working

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check number of row prior to displaying gridview 10 72
Please explain purpose of GZIP 4 59
How to repeat the data 4 30
asp.net repeater 2 12
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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