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

IIF Statement in Access is cutting off my string in c#

I have a field with data type of memo in my access database. I run a
query from c# to access this field and it cuts off my string to only
255 characters. If i run this query directly in access it works fine.
If i run this query without the iif statement it works fine. It only
cuts off my string when i run this query in c# WITH the iif statement.
Here is the statement that doesn't work.

SELECT
IIF(ISNULL(t1.field1), t2.field1, t1.field1) AS desc
FROM
table1 t1 LEFT JOIN t2 ON t1.field2 = t2.field2

If you run this in access it works. If you change it to:

SELECT
t1.field1
FROM
table1 t1

it works fine.

It just doesn't work in c#. Can anyone help

Mar 22 '06 #1
4 3009
Dave,

I think this is something to do with the datatypes.

When you run a query i.e. Select text_field_1 from MyTable, you are directly
accessing that field, thus returning the type as well.

However using compound statements or functions inside the query, afaik, you
are not directly accessing that field, you are actually accessing the return
result from the function.

Have you tried creating and calling a query from within access rather than
accessing the table directly?

Regards
Scott Blood
C# Developer

"Dave" <dc*****@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
I have a field with data type of memo in my access database. I run a
query from c# to access this field and it cuts off my string to only
255 characters. If i run this query directly in access it works fine.
If i run this query without the iif statement it works fine. It only
cuts off my string when i run this query in c# WITH the iif statement.
Here is the statement that doesn't work.

SELECT
IIF(ISNULL(t1.field1), t2.field1, t1.field1) AS desc
FROM
table1 t1 LEFT JOIN t2 ON t1.field2 = t2.field2

If you run this in access it works. If you change it to:

SELECT
t1.field1
FROM
table1 t1

it works fine.

It just doesn't work in c#. Can anyone help

Mar 22 '06 #2
Hi,

"Dave" <dc*****@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
I have a field with data type of memo in my access database. I run a
query from c# to access this field and it cuts off my string to only
255 characters. If i run this query directly in access it works fine.
If i run this query without the iif statement it works fine. It only
cuts off my string when i run this query in c# WITH the iif statement.
Here is the statement that doesn't work.


Can you post the code ni question? a String in C# is not limited to 255
chars , and I believe Access does not impose that limit iehter

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 22 '06 #3
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:O1**************@TK2MSFTNGP11.phx.gbl...
Hi,

"Dave" <dc*****@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
I have a field with data type of memo in my access database. I run a
query from c# to access this field and it cuts off my string to only
255 characters. If i run this query directly in access it works fine.
If i run this query without the iif statement it works fine. It only
cuts off my string when i run this query in c# WITH the iif statement.
Here is the statement that doesn't work.
Can you post the code ni question? a String in C# is not limited to 255
chars , and I believe Access does not impose that limit iehter


Access Text is <= 255 characters
Memo allows storing larger amounts of text.

Are t1.field1 and t2.field1 both Memo, or is one Text and one Memo?

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Mar 23 '06 #4
Hello,

I have investigated this further and it seems that the IIF statement cannot
return an object or binary type field such as a memo field, thus converting
it back to a Text type field.

Regards
Scott Blood
C# Developer

"Ben Voigt" <bv****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:O1**************@TK2MSFTNGP11.phx.gbl...
Hi,

"Dave" <dc*****@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
I have a field with data type of memo in my access database. I run a
query from c# to access this field and it cuts off my string to only
255 characters. If i run this query directly in access it works fine.
If i run this query without the iif statement it works fine. It only
cuts off my string when i run this query in c# WITH the iif statement.
Here is the statement that doesn't work.


Can you post the code ni question? a String in C# is not limited to 255
chars , and I believe Access does not impose that limit iehter


Access Text is <= 255 characters
Memo allows storing larger amounts of text.

Are t1.field1 and t2.field1 both Memo, or is one Text and one Memo?

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


Mar 24 '06 #5

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

Similar topics

5
by: Liberal | last post by:
I am looking for the simplest forum, bbs script which has those features? new messages will be displayed only after the administrator reviewed allow users post without signing up display the...
11
by: Colleyville Alan | last post by:
I posted that I was having trouble with a SQL statement that was working in the SQL window, but not in VBA. I have since discovered that when I create the string in VBA it is over 1023 characters...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
19
by: Arjen | last post by:
Hi, Inside my method I'm using the using-statement for data access. Before that, I create an object of a class. This works fine. Inside the using-statement I set properties of the class (with...
2
by: Bobby | last post by:
Hello, Is it possible, in Access, to base the criteria of a query on another query. Here's an example of what I mean: SELECT ORDER_NO, DESC, TYPE, NAME FROM WHERE (((.)= SELECT JobID from...
2
by: Bobby | last post by:
Hi, Not sure if this is Access, SQL or ODBC. I have a SQL database with an Access Front End. They are linked with ODBC. Occasionally (it's happened 3 times in 4 months) some of the linked tables...
5
by: bhodgins | last post by:
Hi, I am new on here, and had a newbie question that I am stumped with. I am not new to access, but am new to VB. I am trying to export BLOBs from a field called photo to external jpeg files. I...
7
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.