Solved

problem with CStr in my vb component?

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now