473,509 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

specified cast not valid

Form1.WindowState = (FormWindowState) rows[1]["AttributeValue"];

hi i get the following error when i try to do the above . why is taht?
thnx
Nov 16 '05 #1
6 1739
frazer <ic***@hotmail.com> wrote:
Form1.WindowState = (FormWindowState) rows[1]["AttributeValue"];

hi i get the following error when i try to do the above . why is taht?


Presumably because rows[1]["AttributeValue"] isn't a FormWindowState.
What is is it, actually?

Print out rows[1]["AttributeValue"].GetType() to find out.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
string
how do i cast?
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
frazer <ic***@hotmail.com> wrote:
Form1.WindowState = (FormWindowState) rows[1]["AttributeValue"];

hi i get the following error when i try to do the above . why is taht?


Presumably because rows[1]["AttributeValue"] isn't a FormWindowState.
What is is it, actually?

Print out rows[1]["AttributeValue"].GetType() to find out.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
I am actually storing this in a dataset
can i store it as a Form.WindowState ? in the dataset?
or something generic like object. i tried anyType but it didnt work
thnx

"frazer" <ic***@hotmail.com> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...
string
how do i cast?
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
frazer <ic***@hotmail.com> wrote:
Form1.WindowState = (FormWindowState) rows[1]["AttributeValue"];

hi i get the following error when i try to do the above . why is taht?


Presumably because rows[1]["AttributeValue"] isn't a FormWindowState.
What is is it, actually?

Print out rows[1]["AttributeValue"].GetType() to find out.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 16 '05 #4
frazer <ic***@hotmail.com> wrote:
string
how do i cast?
You can't cast from a string to FormWindowState - although you could
use Enum.Parse to get a value.
I am actually storing this in a dataset
can i store it as a Form.WindowState ? in the dataset?
Yup.
or something generic like object. i tried anyType but it didnt work


You can put anything you like in a dataset. When you create the column,
put in the type that you're interested in - in this case,
typeof(FormWindowState).

Of course, you won't be able to put a FormWindowState into an actual
database directly - you'd need to convert to either an int
representation or a string representation.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
i have created my dataset manually not thru code.
and i dont see any type thats generic.
how do i store my form.windowstate ..in what datatype of the dataset.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
frazer <ic***@hotmail.com> wrote:
string
how do i cast?


You can't cast from a string to FormWindowState - although you could
use Enum.Parse to get a value.
I am actually storing this in a dataset
can i store it as a Form.WindowState ? in the dataset?


Yup.
or something generic like object. i tried anyType but it didnt work


You can put anything you like in a dataset. When you create the column,
put in the type that you're interested in - in this case,
typeof(FormWindowState).

Of course, you won't be able to put a FormWindowState into an actual
database directly - you'd need to convert to either an int
representation or a string representation.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #6
frazer <ic***@hotmail.com> wrote:
i have created my dataset manually not thru code.
Good.
and i dont see any type thats generic.
What do you mean by that? Sorry, I don't understand.
how do i store my form.windowstate ..in what datatype of the dataset.


You can store it as FormWindowState, using typeof(FormWindowState).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7

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

Similar topics

0
3610
by: Tao | last post by:
I just upgraded .NET framework to 1.1 and VS.Net to 2003 version and tried to test it out. I created an ASP.NET project using the wizard and tried to run it by hitting "F5". I got an exception:...
2
3082
by: Fabian | last post by:
Hi, I work with asp.net 2.0 and I have a intermittent error, only happens a few times a day. In the page I evaluate a Query String and then I get data form a database. The code snipped: ...
0
623
by: QA | last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003 using SQL Server 2005 I am getting the following error: Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is...
0
1600
by: Alan Z. Scharf | last post by:
this question in datagrid group for several days with no repsonse. I'm hoping for an answer her because of greater activity in this group. No cross-posting intended. Thanks....
0
367
by: Tao | last post by:
I just upgraded .NET framework to 1.1 and VS.Net to 2003 version and tried to test it out. I created an ASP.NET project using the wizard and tried to run it by hitting "F5". I got an exception:...
0
7234
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
7136
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
7344
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,...
1
7069
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
7505
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
5652
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,...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.