[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

problem with CStr in my vb component?

Posted on 2000-02-16
5
Medium Priority
?
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 20 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

649 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