Solved

problem with CStr in my vb component?

Posted on 2000-02-16
5
225 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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