473,406 Members | 2,259 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,406 software developers and data experts.

using an alias in a where statement as a parameter

Hello,

I have the following tables and have setup the following sql statement as part of my data adapter. The problem is that I need to do a statement that will find the records selected in my list box. I cannot figure out how to use the "name' alias in the parameter statement.

I am trying to combine first, last name, alpha number into one field for the list box and all the requests the employee made.

Here are my two tables:

EmpAlpha RequestID
EmpFirstName RequestDate
EmpLastName DivsionID

Here is my SQL statement as it is now. But it does not return the matching requests.

SELECT EmployeeCurrent.EmpLastName + ', ' + ' ' + EmployeeCurrent.EmpFirstName + ' 'EmployeeCurrent.EmpAlpha AS Name,
RequestDesired.RequestID, RequestDesired.RequestDate, RequestDesired.DivisionID, RequestDesired.CodeID
FROM EmployeeCurrent INNER JOIN
RequestDesired ON EmployeeCurrent.EmpAlpha = RequestDesired.EmployeeAlpha
WHERE ('Name' = ? + '%')
ORDER BY RequestDesired.DivisionID

How do I reference the alias for my concatenated 'Name' in the parameter so I can return the right records in the data adapter and set the datasource for my grid to include 'Name'

Debbie

--
debhemlinger - forum member
http://www.visual-basic-data-mining.net/forum
Nov 16 '05 #1
2 1739
Hi Debbie
One thing that you can do is to send that alias as an input parameter, then
add this parameter to the parameter collection of you command object then
in your command text refer to it by the parameter name ( where alias = @
alias_param )
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2
If I follow ths right, this line:
WHERE ('Name' = ? + '%')
should be
WHERE ([Name] = ? + '%')

As you had it, you were trying to match the literal string 'Name' against
the parameter.
--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)
"http://www.visual-basic-data-mining.net/forum" <si******@gmail.com> wrote
in message news:%2****************@tk2msftngp13.phx.gbl...
Hello,

I have the following tables and have setup the following sql statement as
part of my data adapter. The problem is that I need to do a statement that
will find the records selected in my list box. I cannot figure out how to
use the "name' alias in the parameter statement.

I am trying to combine first, last name, alpha number into one field for the
list box and all the requests the employee made.

Here are my two tables:

EmpAlpha RequestID
EmpFirstName RequestDate
EmpLastName DivsionID

Here is my SQL statement as it is now. But it does not return the matching
requests.

SELECT EmployeeCurrent.EmpLastName + ', ' + ' ' +
EmployeeCurrent.EmpFirstName + ' 'EmployeeCurrent.EmpAlpha AS Name,
RequestDesired.RequestID, RequestDesired.RequestDate,
RequestDesired.DivisionID, RequestDesired.CodeID
FROM EmployeeCurrent INNER JOIN
RequestDesired ON EmployeeCurrent.EmpAlpha =
RequestDesired.EmployeeAlpha
WHERE ('Name' = ? + '%')
ORDER BY RequestDesired.DivisionID

How do I reference the alias for my concatenated 'Name' in the parameter so
I can return the right records in the data adapter and set the datasource
for my grid to include 'Name'

Debbie

--
debhemlinger - forum member
http://www.visual-basic-data-mining.net/forum
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. ...
14
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The...
2
by: Jessard | last post by:
Help! Hi, I'm having a bit (well a lot - it's getting annoying) of trouble using a C# class library within a VBScript on a computer other than the development machine. All the class is needed...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
9
by: Ron | last post by:
Hello, Is it required to use Imports System.Runtime.InteropServices to run C++ API code? I ask because I thought I read somewhere that this was required. If it is not required would it...
0
by: Mike S | last post by:
I've seen examples of using the CallWindowProc Windows API function to call functions through their addresses in VB6 -- a clever workaround to emulate C-like function pointer semantics. A...
15
by: arnuld | last post by:
-------- PROGRAMME ----------- /* Stroustrup, 5.6 Structures STATEMENT: this programmes *tries* to do do this in 3 parts: 1.) it creates a "struct", named "jd", of type "address". 2. it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.