SQL Wildcard and @variable not working
Posted on 2004-08-10
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