473,396 Members | 1,799 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,396 software developers and data experts.

Can't concatenate for data adapters

Just starting with ASP.NET and Pulling from data from an Access Database so
I'm using the OleDbDataAdapter

I'm trying to create two data adapters...

daActorNames

daActor

I've successfully created daActor

But for daActorNames the following (which works in T-SQL) just doesn't work

SELECT ActorID, LastName + N', ' + FirstName + N' ' + ISNULL(MiddleName,
N'') AS Actor
FROM tblActors
ORDER BY LastName

I'm trying to produce the following

ActorID Actor
123 LastName, FirstName MI (if there is one... nothing if there
isn't)
Why doesnt' this work in or out of the query builder?

Nov 19 '05 #1
5 1087
Jonefer,

I'm not positive if access understands the "N", but I know you don't need
it. Also I'm unclear whether your ISNULL is allowed or not but I don't
understand why you'd need it. If MiddleName is NULL then it just won't be
included. Give this a try:

SELECT ActorID, (LastName + ', ' + FirstName + ' ' + MiddleName) AS
Actor
FROM tblActors
ORDER BY LastName

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
Just starting with ASP.NET and Pulling from data from an Access Database
so
I'm using the OleDbDataAdapter

I'm trying to create two data adapters...

daActorNames

daActor

I've successfully created daActor

But for daActorNames the following (which works in T-SQL) just doesn't
work

SELECT ActorID, LastName + N', ' + FirstName + N' ' +
ISNULL(MiddleName,
N'') AS Actor
FROM tblActors
ORDER BY LastName

I'm trying to produce the following

ActorID Actor
123 LastName, FirstName MI (if there is one... nothing if there
isn't)
Why doesnt' this work in or out of the query builder?


Nov 19 '05 #2
Ok, I was hoping someone else would say that...
I tried what you said, and then this is how it interpreted that:

SELECT ActorID, LastName + ',
' + FirstName + ' ' + MiddleName AS Actor FROM tblActors ORDER BY LastName

My resultant set looks like this

ActorID Actor
===== =======
123 LastName,
124 LastName,
125 Null
126 Null

No matter what I try, I haven't been able to get the firstname to show...
unless I completely eliminate the comma.

But another KEY thing you said is that you're not sure "ACCESS" understands
'N'
so... should I do what I already know works in Access?

SELECT LastName & ", " & FirstName & & " " nz(MiddleName, "")

I tried that, and it doesn't like the & (ampersand)



"S. Justin Gengo" wrote:
Jonefer,

I'm not positive if access understands the "N", but I know you don't need
it. Also I'm unclear whether your ISNULL is allowed or not but I don't
understand why you'd need it. If MiddleName is NULL then it just won't be
included. Give this a try:

SELECT ActorID, (LastName + ', ' + FirstName + ' ' + MiddleName) AS
Actor
FROM tblActors
ORDER BY LastName

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
Just starting with ASP.NET and Pulling from data from an Access Database
so
I'm using the OleDbDataAdapter

I'm trying to create two data adapters...

daActorNames

daActor

I've successfully created daActor

But for daActorNames the following (which works in T-SQL) just doesn't
work

SELECT ActorID, LastName + N', ' + FirstName + N' ' +
ISNULL(MiddleName,
N'') AS Actor
FROM tblActors
ORDER BY LastName

I'm trying to produce the following

ActorID Actor
123 LastName, FirstName MI (if there is one... nothing if there
isn't)
Why doesnt' this work in or out of the query builder?



Nov 19 '05 #3
Jonefer,

Did you remove the parentheses I had in the select I showed you?

Those are key. I know that concatenation works in Access because I tried it.
And the only difference between the select I sent you and the one you show
here is that yours doesn't have the parentheses...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
Ok, I was hoping someone else would say that...
I tried what you said, and then this is how it interpreted that:

SELECT ActorID, LastName + ',
' + FirstName + ' ' + MiddleName AS Actor FROM tblActors ORDER BY
LastName

My resultant set looks like this

ActorID Actor
===== =======
123 LastName,
124 LastName,
125 Null
126 Null

No matter what I try, I haven't been able to get the firstname to show...
unless I completely eliminate the comma.

But another KEY thing you said is that you're not sure "ACCESS"
understands
'N'
so... should I do what I already know works in Access?

SELECT LastName & ", " & FirstName & & " " nz(MiddleName, "")

I tried that, and it doesn't like the & (ampersand)



"S. Justin Gengo" wrote:
Jonefer,

I'm not positive if access understands the "N", but I know you don't need
it. Also I'm unclear whether your ISNULL is allowed or not but I don't
understand why you'd need it. If MiddleName is NULL then it just won't be
included. Give this a try:

SELECT ActorID, (LastName + ', ' + FirstName + ' ' + MiddleName) AS
Actor
FROM tblActors
ORDER BY LastName

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
> Just starting with ASP.NET and Pulling from data from an Access
> Database
> so
> I'm using the OleDbDataAdapter
>
> I'm trying to create two data adapters...
>
> daActorNames
>
> daActor
>
> I've successfully created daActor
>
> But for daActorNames the following (which works in T-SQL) just doesn't
> work
>
> SELECT ActorID, LastName + N', ' + FirstName + N' ' +
> ISNULL(MiddleName,
> N'') AS Actor
> FROM tblActors
> ORDER BY LastName
>
> I'm trying to produce the following
>
> ActorID Actor
> 123 LastName, FirstName MI (if there is one... nothing if
> there
> isn't)
> Why doesnt' this work in or out of the query builder?
>
>
>
>
>


Nov 19 '05 #4
Justin,
No, I didn't remove the parenthesis. VS.NET removes it.
That's what I meant by:

"and then this is how it interpreted that"

I ended up going to my Access Database and creating a field called
ActorName, updated the table and am now using that field.

....but there must be away to do this in Visual Studio.NET
Try it if you can... you won't be able to keep the parenthesis if you use
the Query Builder... maybe I need to set up the adapter through code.


"S. Justin Gengo" wrote:
Jonefer,

Did you remove the parentheses I had in the select I showed you?

Those are key. I know that concatenation works in Access because I tried it.
And the only difference between the select I sent you and the one you show
here is that yours doesn't have the parentheses...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
Ok, I was hoping someone else would say that...
I tried what you said, and then this is how it interpreted that:

SELECT ActorID, LastName + ',
' + FirstName + ' ' + MiddleName AS Actor FROM tblActors ORDER BY
LastName

My resultant set looks like this

ActorID Actor
===== =======
123 LastName,
124 LastName,
125 Null
126 Null

No matter what I try, I haven't been able to get the firstname to show...
unless I completely eliminate the comma.

But another KEY thing you said is that you're not sure "ACCESS"
understands
'N'
so... should I do what I already know works in Access?

SELECT LastName & ", " & FirstName & & " " nz(MiddleName, "")

I tried that, and it doesn't like the & (ampersand)



"S. Justin Gengo" wrote:
Jonefer,

I'm not positive if access understands the "N", but I know you don't need
it. Also I'm unclear whether your ISNULL is allowed or not but I don't
understand why you'd need it. If MiddleName is NULL then it just won't be
included. Give this a try:

SELECT ActorID, (LastName + ', ' + FirstName + ' ' + MiddleName) AS
Actor
FROM tblActors
ORDER BY LastName

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
> Just starting with ASP.NET and Pulling from data from an Access
> Database
> so
> I'm using the OleDbDataAdapter
>
> I'm trying to create two data adapters...
>
> daActorNames
>
> daActor
>
> I've successfully created daActor
>
> But for daActorNames the following (which works in T-SQL) just doesn't
> work
>
> SELECT ActorID, LastName + N', ' + FirstName + N' ' +
> ISNULL(MiddleName,
> N'') AS Actor
> FROM tblActors
> ORDER BY LastName
>
> I'm trying to produce the following
>
> ActorID Actor
> 123 LastName, FirstName MI (if there is one... nothing if
> there
> isn't)
> Why doesnt' this work in or out of the query builder?
>
>
>
>
>


Nov 19 '05 #5
Jonefer,

In that case how about specifying your select as a query in the access
database and then calling that query name from .NET.

That way you'll be calling it the same way you would a stored procedure...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
Justin,
No, I didn't remove the parenthesis. VS.NET removes it.
That's what I meant by:

"and then this is how it interpreted that"

I ended up going to my Access Database and creating a field called
ActorName, updated the table and am now using that field.

...but there must be away to do this in Visual Studio.NET
Try it if you can... you won't be able to keep the parenthesis if you use
the Query Builder... maybe I need to set up the adapter through code.


"S. Justin Gengo" wrote:
Jonefer,

Did you remove the parentheses I had in the select I showed you?

Those are key. I know that concatenation works in Access because I tried
it.
And the only difference between the select I sent you and the one you
show
here is that yours doesn't have the parentheses...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"jonefer" <jo*****@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
> Ok, I was hoping someone else would say that...
> I tried what you said, and then this is how it interpreted that:
>
> SELECT ActorID, LastName + ',
> ' + FirstName + ' ' + MiddleName AS Actor FROM tblActors ORDER BY
> LastName
>
> My resultant set looks like this
>
> ActorID Actor
> ===== =======
> 123 LastName,
> 124 LastName,
> 125 Null
> 126 Null
>
> No matter what I try, I haven't been able to get the firstname to
> show...
> unless I completely eliminate the comma.
>
> But another KEY thing you said is that you're not sure "ACCESS"
> understands
> 'N'
> so... should I do what I already know works in Access?
>
> SELECT LastName & ", " & FirstName & & " " nz(MiddleName, "")
>
> I tried that, and it doesn't like the & (ampersand)
>
>
>
>
>
>
>
> "S. Justin Gengo" wrote:
>
>> Jonefer,
>>
>> I'm not positive if access understands the "N", but I know you don't
>> need
>> it. Also I'm unclear whether your ISNULL is allowed or not but I don't
>> understand why you'd need it. If MiddleName is NULL then it just won't
>> be
>> included. Give this a try:
>>
>> SELECT ActorID, (LastName + ', ' + FirstName + ' ' + MiddleName)
>> AS
>> Actor
>> FROM tblActors
>> ORDER BY LastName
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "jonefer" <jo*****@discussions.microsoft.com> wrote in message
>> news:FF**********************************@microsof t.com...
>> > Just starting with ASP.NET and Pulling from data from an Access
>> > Database
>> > so
>> > I'm using the OleDbDataAdapter
>> >
>> > I'm trying to create two data adapters...
>> >
>> > daActorNames
>> >
>> > daActor
>> >
>> > I've successfully created daActor
>> >
>> > But for daActorNames the following (which works in T-SQL) just
>> > doesn't
>> > work
>> >
>> > SELECT ActorID, LastName + N', ' + FirstName + N' ' +
>> > ISNULL(MiddleName,
>> > N'') AS Actor
>> > FROM tblActors
>> > ORDER BY LastName
>> >
>> > I'm trying to produce the following
>> >
>> > ActorID Actor
>> > 123 LastName, FirstName MI (if there is one... nothing if
>> > there
>> > isn't)
>> > Why doesnt' this work in or out of the query builder?
>> >
>> >
>> >
>> >
>> >
>>
>>
>>


Nov 19 '05 #6

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

Similar topics

1
by: Bob T | last post by:
Hi, I have been using SQLDataAdapters and Datasets in my project. I have a goal to simplify the project. Each data adapter has a corresponding dataset it retrieves values into. Even though...
5
by: amanatio | last post by:
I have a huge form with many data bound controls on it and 34 tables in database (and of course 34 data adapters and 34 datasets). The form is extremely slow to design (huge delay when I go to code...
3
by: Robin | last post by:
When adding a SQL Data Adapter to a page, is possible to configure it use a connection string in code? As I have found it regenerates the code each time and of the adapters are modified and does...
0
by: Paul Craig | last post by:
Hi everyone, I have recently upgraded several of my projects from Visual Studio 2003 to 2005 and everything went across quite smoothly. The main problem that I am having is I have used SQL Data...
6
by: Sheldon | last post by:
Hi, I am trying to build a large array using concatenate function in python. So as I loop over the number of arrays, of which there are 12 (4 down and 3 across), I create 3 long arrays by...
5
by: Generic Usenet Account | last post by:
I have been to recreate a problem that I am having with strings with the trivial code snippet given below. In the trivial code example, I am reading five lines from a data file, each line having...
12
by: Randy | last post by:
Hi, Trying to pass along a table row delete to the datasource, but I'm crashing. Here is the code: Private Sub btnDeleteIngr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
2
by: Orit | last post by:
Hello . Please find below my questions - I hope some of the ASP.NET experts of this forum will answer to those beginner's questions : My Web site should be able to work with either SQL Server...
7
by: maheshinvent | last post by:
Hello friends I need to know how data packets are actually transferred through network adapters...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.