Solved

problem with CStr in my vb component?

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP Button to clear text 4 69
Select record with the most recent date 14 71
Code Manager | Snippits 2 66
JQuery on multiple lines 3 18
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

696 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