typcast in sql statement ignored by tableadapter?

B

Benj Nunez

Hello experts,

I've written a winform app that uses MS Access as my database. My sql
statement in a table adapter has this line:

SELECT USERID, BADGENUMBER, SSN, NAME, ATT, INLATE, OUTEARLY,
OVERTIME, SEP, HOLIDAY, LUNCHDURATION
FROM USERINFO
ORDER BY BADGENUMBER

Since the data type for BadgeNumber is of type "Text", the result is
not arranged properly because it's a string. Our solution then is to
introduce a cast using Val() so:

SELECT USERID, BADGENUMBER, SSN, NAME, ATT, INLATE, OUTEARLY,
OVERTIME, SEP, HOLIDAY, LUNCHDURATION
FROM USERINFO
ORDER BY VAL(BADGENUMBER)

Data gets sorted using this line, however, once I start compiling my
C# code, I get an error like:

"Error 1 The type or namespace name 'att2000DataSet' could not be
found (are you missing a using directive or an assembly reference?) D:
\Benj\CSharp Solution\EmployeeDataEntryForm
\ver1306\MainForm.Designer.cs 768 17 EmployeeMaintenance".

My question is, how come I get this error message when I didn't even
change a single line of code in my C# project, notably from my
MainForm.Designer.cs file?

Can someone help me out with this? Thanks in advance.

Benj
 
N

Nicholas Paldino [.NET/C# MVP]

Benj,

Have you tried removing and then readding the data set to your project?
I imagine that maybe the IDE might have some problems with the statement
(although I can't imagine why).

Also, why not change the type of the field to an integer or numeric
value? If it is going to be selected this way, then the assumption is that
it can ALWAYS be converted, and if that is the case, then a string is an
inappropriate data type for the storage.
 
B

Benj Nunez

Hi!

I already set the data type of the BADGENUMBER field from "text" to
"Numeric". It works great. Although I have to explain this to my boss
because of the sudden change in the table structure. Initially I
wanted to handle the table
without touching any of its field as advised by our superiors. Perhaps
this might be an exemption rather than the rule.


Benj



Benj,

Have you tried removing and then readding the data set to your project?
I imagine that maybe the IDE might have some problems with the statement
(although I can't imagine why).

Also, why not change the type of the field to an integer or numeric
value? If it is going to be selected this way, then the assumption is that
it can ALWAYS be converted, and if that is the case, then a string is an
inappropriate data type for the storage.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Hello experts,
I've written a winform app that uses MS Access as my database. Mysql
statement in a table adapter has this line:
SELECT USERID, BADGENUMBER, SSN, NAME, ATT, INLATE, OUTEARLY,
OVERTIME, SEP, HOLIDAY, LUNCHDURATION
FROM USERINFO
ORDER BY BADGENUMBER
Since the data type for BadgeNumber is of type "Text", the result is
not arranged properly because it's a string. Our solution then is to
introduce a cast using Val() so:
SELECT USERID, BADGENUMBER, SSN, NAME, ATT, INLATE, OUTEARLY,
OVERTIME, SEP, HOLIDAY, LUNCHDURATION
FROM USERINFO
ORDER BY VAL(BADGENUMBER)
Data gets sorted using this line, however, once I start compiling my
C# code, I get an error like:
"Error 1 The type or namespace name 'att2000DataSet' could not be
found (are you missing a using directive or an assembly reference?) D:
\Benj\CSharp Solution\EmployeeDataEntryForm
\ver1306\MainForm.Designer.cs 768 17 EmployeeMaintenance".
My question is, how come I get this error message when I didn't even
change a single line of code in my C# project, notably from my
MainForm.Designer.cs file?
Can someone help me out with this? Thanks in advance.
 
B

Benj Nunez

I have tried your suggestion btw. It didn't work. :(


Benj,

Have you tried removing and then readding the data set to your project?
I imagine that maybe the IDE might have some problems with the statement
(although I can't imagine why).

Also, why not change the type of the field to an integer or numeric
value? If it is going to be selected this way, then the assumption is that
it can ALWAYS be converted, and if that is the case, then a string is an
inappropriate data type for the storage.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Hello experts,
I've written a winform app that uses MS Access as my database. My sql
statement in a table adapter has this line:
SELECT USERID, BADGENUMBER, SSN, NAME, ATT, INLATE, OUTEARLY,
OVERTIME, SEP, HOLIDAY, LUNCHDURATION
FROM USERINFO
ORDER BY BADGENUMBER
Since the data type for BadgeNumber is of type "Text", the result is
not arranged properly because it's a string. Our solution then is to
introduce a cast using Val() so:
SELECT USERID, BADGENUMBER, SSN, NAME, ATT, INLATE, OUTEARLY,
OVERTIME, SEP, HOLIDAY, LUNCHDURATION
FROM USERINFO
ORDER BY VAL(BADGENUMBER)
Data gets sorted using this line, however, once I start compiling my
C# code, I get an error like:
"Error 1 The type or namespace name 'att2000DataSet' could not be
found (are you missing a using directive or an assembly reference?) D:
\Benj\CSharp Solution\EmployeeDataEntryForm
\ver1306\MainForm.Designer.cs 768 17 EmployeeMaintenance".
My question is, how come I get this error message when I didn't even
change a single line of code in my C# project, notably from my
MainForm.Designer.cs file?
Can someone help me out with this? Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top