Solved

problem with CStr in my vb component?

Posted on 2000-02-16
5
226 Views
Last Modified: 2006-11-17
I have a private variable:

private nValue as Long

When I use this value after it has been set in a string I keep getting mismatch errors:

    sSql = "SELECT Business_Entity_Name, Primary_Entity_ID, Entity_Type_ID, " + _
           "User_Rights.Business_Entity_ID AS Business_Entity_ID, User_Rights_ID " + _
           "FROM User_Rights, User_Info, Business_Entity WHERE User_Rights.User_ID = " + cstr(nValue ) + _
           " AND Business_Entity.Business_Entity_ID = User_Rights.Business_Entity_ID"

I have also tried
CInt( nValue )

it only works when I do this:
    sSql = "SELECT Business_Entity_Name, Primary_Entity_ID, Entity_Type_ID, " + _
           "User_Rights.Business_Entity_ID AS Business_Entity_ID, User_Rights_ID " + _
           "FROM User_Rights, User_Info, Business_Entity WHERE User_Rights.User_ID = 1" + _
           " AND Business_Entity.Business_Entity_ID = User_Rights.Business_Entity_ID"

any ideas why I have this problem?

0
Comment
Question by:eric07
5 Comments
 
LVL 6

Expert Comment

by:Marine
ID: 2529311
Have you tried using Val(nValue) ?
0
 

Author Comment

by:eric07
ID: 2529336
tried it but no luck.
Any other suggestions?

anyone
0
 
LVL 1

Expert Comment

by:Aemergin
ID: 2529501
It looks like your field "User_Rights.User_ID" is looking for an integer .. use CInt(nValue) instead of CStr(nValue).

-Aemergin
0
 
LVL 10

Accepted Solution

by:
Yury_Delendik earned 10 total points
ID: 2530218
The concatination operation is not +, it's & (if it isn't javascript code :) ). Try it.

sSql = "SELECT Business_Entity_Name, Primary_Entity_ID, Entity_Type_ID, " & _
           "User_Rights.Business_Entity_ID AS Business_Entity_ID, User_Rights_ID " & _
           "FROM User_Rights, User_Info, Business_Entity WHERE User_Rights.User_ID = " & nValue & _
           " AND Business_Entity.Business_Entity_ID = User_Rights.Business_Entity_ID"
0
 
LVL 1

Expert Comment

by:Aemergin
ID: 2531789
The concatination is obviously not the problem, Yury, as he stated earlier, his second SQL string worked properly. The problem lies in converting the variable to the proper datatype - in this case either a number or integer.

Again, using CInt(nValue) should do exactly what you need, eric07.

-Aemergin
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

838 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