WebService Return bing cut off at 40 chars asp.net VB

I am trying to return an encriptyed id from a table that is about 60 chars. But every time I run the web service it limits the return to 40 chars.

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data.SqlClient
Imports System.Data

<WebService(Namespace:="http://blah.com/")> Public Class LeasorVerify

    Inherits System.Web.Services.WebService
    <WebMethod()> _
       Public Function LeasorVerify(ByVal UserName As String, ByVal Password As String) As System.Data.DataSet
        Dim conn As New System.Data.SqlClient.SqlConnection("Database=DB;Server=Server;uid=username;passwordPassword")
        Dim ds As New System.Data.DataSet()
        Dim adapter As New System.Data.SqlClient.SqlDataAdapter()
        adapter.SelectCommand = New System.Data.SqlClient.SqlCommand("EXEC      [dbo].[sp_Verify]  @UserName = " & UserName & ",@Password=" & Password, conn)
        adapter.Fill(ds, "Info")
        Return ds
    End Function

End Class

This returns the name of the customer and a encrypeted id. The encrypted id that is returned is 40 chars everytime.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
You should be able to specify the length of each parameter like this:

        adapter.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UserName", System.Data.SqlDbType.VarChar, 50, "UserName"))
        adapter.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Password", System.Data.SqlDbType.VarChar, 100, "Password"))
From what I see in your code, it does not sound like a problem with your input parameters. I suggest you investigate the [sp_Verify] stored procedure. Check that the encrypted string is not being restricted... there might be a SELECT CAST(fieldInQuestion as varchar(40)) or something that is affecting you there.

Also check if executing that stored procedure directly from SQL Server Management Studio returns the correct data...
soccerman767Author Commented:
Yes it does return the correct data from the SP
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

you need quotes in this line:

adapter.SelectCommand = New System.Data.SqlClient.SqlCommand("EXEC      [dbo].[sp_Verify]  @UserName = " & UserName & ",@Password=" & Password, conn)

Open in new window

like so:

adapter.SelectCommand = New System.Data.SqlClient.SqlCommand("EXEC      [dbo].[sp_Verify]  @UserName = '" & UserName & "',@Password='" & Password & "'", conn)

Open in new window

as to the truncation... I'm afraid I cannot see where that could be coming from since the stored procedure returns the correct data. what datatypes are the columns in the return data? is there some form of conversion being done by .NET?
soccerman767Author Commented:
The field in the table is varbinary(max). I am not declaring a return variable. The SP is just returing the results of an query.    

I am new to web services so I am assuming it is like you say      a .net limit on the return string.
aha! varbinary(max) is the problem!

maybe try to convert the data into a hex string first check this article out about how best to deal with this: http://sqlblog.com/blogs/peter_larsson/archive/2010/01/27/convert-binary-value-to-string-value.aspx

anyway.. the issue is that in order to read the actaul data in a varbinary column, you have to stream the data from teh dataset.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
if you have sql server 2005, try to view the varbinary column. you will see that it does not really show the data... well.. it's something along those lines. am not too sure how best to return a varbinary column from a web service.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.