473,385 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Variable Values inside Global Strings

DeathsBain
ok... just a pre-note: i am an old unix c/c++ programmer, this visual programming thing is new to me so please accept my apologizes in advance for my ignorance...


that being said, here is my situation --

i am in the process of creating a "Time Keeper & Attendance Program" we call it TKAP :)

i am working on a screen that has a combo-box that has pay-cycle ending dates in it that are populated by a mysql db table. the dates and the combo-box work great. when the data is changed in the combo-box, my code takes and calls a function that goes and needs to look up the status of an end users time that has been submitted... that information is stored in a table called "statusofhours". what i am checking against is to see if they have already submitted their hours for this pay-cycle which would give me a "SH" in a field, not yet submitted - "NS" and already approved -- "AP"

well to make sure that i am checking the correct information i am using a string called "CheckStatusTable" which has the following information in it:

Expand|Select|Wrap|Line Numbers
  1. Public CheckStatusTable As String = "select * from `statusofhours` where `username`='" + username + "'"
**explination** the "username" at the end of that statement is a global variable that is set to hold the login name of the user that logged in... that part works fine it does store the name correctly...

the problem that i am running into is that when the code executes, the output of the sql statment is:
Expand|Select|Wrap|Line Numbers
  1. select * from `statusofhours` where `username`="
that is all i am getting... so i guess my main question is, how do i get the value that is in the global variable "username" to be part of the sql string???


any and all help would be really appreciated... you can contact me either by:
posting here,
email me (prefered) at: williamgATmalcoproDOTcom,
or IM me (prefered also) at deathsbainATsbcglobalDOTnet (yahoo) or usswilliamgray (AIM)


thanks once again for all your help!!!


Deathsbain -- Have you hugged your undertaker today???
Feb 2 '07 #1
3 1099
Killer42
8,435 Expert 8TB
From the sound of it, you are populating the sql string before the username variable has a value. You need to put together the SELECT statement after you have loaded the username into the global variable - perhaps at the point just before using the sql string. I realise this might seem like extra work, if the username is only set once at login. The important thing is simply that they happen in the correct sequence - setting the sql string just before using it is just sort of the extreme case which would ensure that happened.

Quick question - do you have Option Explicit set? If not, it's always possible you're actually using a non-existent variable somewhere.

Oh, I almost forgot to ask - what version of VB?
Feb 2 '07 #2
willakawill
1,646 1GB
You also have the field username in inverted commas. In sql this indicates a literal string and not a fieldname.
Feb 2 '07 #3
Killer42
8,435 Expert 8TB
You also have the field username in inverted commas. In sql this indicates a literal string and not a fieldname.
Actually, I wondered a bit about those, but forgot it when typing my response. (Honest! :))

If we're talking detail, those aren't proper inverted commas, either. They look as though they were converted to "smart quotes" by Word or something.
Feb 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Brian Leair | last post by:
I am using "from MyModule import *", (yes, yes, I know) MyModule has a variable "g_my_var" at the "global" scope. In the code that performs the import, I have a function that has the statement...
2
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
10
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if I declare a global variable in my pages code behind, is it persisted if the page does a post back, or do I need to add the object to the session object in...
9
by: ruca | last post by:
How can I declare a global variable in my .js file, that I can preserve her value each time I need to call any function of .JS file in my ASP.NET application? Example: var aux=null; function...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
4
by: Ray | last post by:
Hello, I think I've had JavaScript variable scope figured out, can you please see if I've got it correctly? * Variables can be local or global * When a variable is declared outside any...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
by: Konstantinos Pachopoulos | last post by:
Hi, i have a problem, the source of which is probably the fact, that i have not understood how to declare global variables - I use the Jython compiler, but i think this is a Python issue... ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.