Data Type Error Reading from database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thanks Memnoch,

I have got round with that error and now something else has cropped up. My
guess is that its something to do with data conversion.

I am getting this error, In my database, the field LoginName is set as
Vachar type. It looks as though there is a problem reading this field. could
you please enlighting me on what I have done wrong and what i could do to
correct this error.

Thanks for you Help.


''----------------------Error-------------------------
The data value could not be converted for reasons other than sign mismatch
or data overflow. For example, the data was corrupted in the data store but
the row was still retrievable.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidCastException: The data value could not be
converted for reasons other than sign mismatch or data overflow. For example,
the data was corrupted in the data store but the row was still retrievable.

Source Error:

Line 56: authorisedusernameList.Items.Add( dataReader.GetString( 0 ) );

Source File: c:\inetpub\wwwroot\websupportproject\login.aspx.cs Line: 56

Stack Trace:
[InvalidCastException: The data value could not be converted for reasons
other than sign mismatch or data overflow. For example, the data was
corrupted in the data store but the row was still retrievable.]
System.Data.OleDb.DBBindings.get_ValueString()
System.Data.OleDb.OleDbDataReader.GetString(Int32 ordinal)
WebsupportProject.Login.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\websupportproject\login.aspx.cs:56
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
'---------------end of error------------------------------



Thank you for your help so far.
 
Kojo,

Hard to say without setting a breakpoint at the offending line and checking
the values - but one of the possible fixes could be to change this line -

authorisedusernameList.Items.Add( dataReader.GetString( 0 ) );

to

authorisedusernameList.Items.Add( dataReader.GetString( 0 ).ToString() );

or

authorisedusernameList.Items.Add( (string) dataReader.GetString( 0 ) );

BTW, what is the datatype at column #0?

Again - the above might not be why you are getting this error, but it is
hard to debug without your setting a breakpoint and examining the value of
dataReader.GetString(0).

Another reason could be - you might not be getting any rows back out of your
query.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik

kojosmooth said:
Thanks Memnoch,

I have got round with that error and now something else has cropped up. My
guess is that its something to do with data conversion.

I am getting this error, In my database, the field LoginName is set as
Vachar type. It looks as though there is a problem reading this field. could
you please enlighting me on what I have done wrong and what i could do to
correct this error.

Thanks for you Help.


''----------------------Error-------------------------
The data value could not be converted for reasons other than sign mismatch
or data overflow. For example, the data was corrupted in the data store but
the row was still retrievable.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidCastException: The data value could not be
converted for reasons other than sign mismatch or data overflow. For example,
the data was corrupted in the data store but the row was still retrievable.

Source Error:

Line 56: authorisedusernameList.Items.Add( dataReader.GetString( 0 ) );

Source File: c:\inetpub\wwwroot\websupportproject\login.aspx.cs Line: 56

Stack Trace:
[InvalidCastException: The data value could not be converted for reasons
other than sign mismatch or data overflow. For example, the data was
corrupted in the data store but the row was still retrievable.]
System.Data.OleDb.DBBindings.get_ValueString()
System.Data.OleDb.OleDbDataReader.GetString(Int32 ordinal)
WebsupportProject.Login.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\websupportproject\login.aspx.cs:56
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
'---------------end of error------------------------------



Thank you for your help so far.
 
Hi Sahil,
Thanks for tolerating my bugging you with my queries, I have got round the
problem by using authorisedusernameList.Items.Add(
dataReader["LoginName"].ToString( ) ); (i got this help from another good guy
from a forum)
The code woks but unfortunately it doesn't show anything in the dropdwon list.
Thanks for your help, i'll try and figure out what I have gone wrong.

Cheers

Sahil Malik said:
Kojo,

Hard to say without setting a breakpoint at the offending line and checking
the values - but one of the possible fixes could be to change this line -

authorisedusernameList.Items.Add( dataReader.GetString( 0 ) );

to

authorisedusernameList.Items.Add( dataReader.GetString( 0 ).ToString() );

or

authorisedusernameList.Items.Add( (string) dataReader.GetString( 0 ) );

BTW, what is the datatype at column #0?

Again - the above might not be why you are getting this error, but it is
hard to debug without your setting a breakpoint and examining the value of
dataReader.GetString(0).

Another reason could be - you might not be getting any rows back out of your
query.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik

kojosmooth said:
Thanks Memnoch,

I have got round with that error and now something else has cropped up. My
guess is that its something to do with data conversion.

I am getting this error, In my database, the field LoginName is set as
Vachar type. It looks as though there is a problem reading this field. could
you please enlighting me on what I have done wrong and what i could do to
correct this error.

Thanks for you Help.


''----------------------Error-------------------------
The data value could not be converted for reasons other than sign mismatch
or data overflow. For example, the data was corrupted in the data store but
the row was still retrievable.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidCastException: The data value could not be
converted for reasons other than sign mismatch or data overflow. For example,
the data was corrupted in the data store but the row was still retrievable.

Source Error:

Line 56: authorisedusernameList.Items.Add( dataReader.GetString( 0 ) );

Source File: c:\inetpub\wwwroot\websupportproject\login.aspx.cs Line: 56

Stack Trace:
[InvalidCastException: The data value could not be converted for reasons
other than sign mismatch or data overflow. For example, the data was
corrupted in the data store but the row was still retrievable.]
System.Data.OleDb.DBBindings.get_ValueString()
System.Data.OleDb.OleDbDataReader.GetString(Int32 ordinal)
WebsupportProject.Login.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\websupportproject\login.aspx.cs:56
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
'---------------end of error------------------------------



Thank you for your help so far.
 
Kojo,

I don't mind your queries at all.

Try this - set a breakpoint there, see what that ToString evaluates to.
There is a neat little immediate window, or you can simply select the
expression at hit SHIFT_F9 to bring up a quickwatch window.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



kojosmooth said:
Hi Sahil,
Thanks for tolerating my bugging you with my queries, I have got round the
problem by using authorisedusernameList.Items.Add(
dataReader["LoginName"].ToString( ) ); (i got this help from another good
guy
from a forum)
The code woks but unfortunately it doesn't show anything in the dropdwon
list.
Thanks for your help, i'll try and figure out what I have gone wrong.

Cheers

Sahil Malik said:
Kojo,

Hard to say without setting a breakpoint at the offending line and
checking
the values - but one of the possible fixes could be to change this line -

authorisedusernameList.Items.Add( dataReader.GetString( 0 ) );

to

authorisedusernameList.Items.Add( dataReader.GetString( 0 ).ToString() );

or

authorisedusernameList.Items.Add( (string) dataReader.GetString( 0 ) );

BTW, what is the datatype at column #0?

Again - the above might not be why you are getting this error, but it is
hard to debug without your setting a breakpoint and examining the value
of
dataReader.GetString(0).

Another reason could be - you might not be getting any rows back out of
your
query.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik

kojosmooth said:
Thanks Memnoch,

I have got round with that error and now something else has cropped up.
My
guess is that its something to do with data conversion.

I am getting this error, In my database, the field LoginName is set as
Vachar type. It looks as though there is a problem reading this field. could
you please enlighting me on what I have done wrong and what i could do
to
correct this error.

Thanks for you Help.


''----------------------Error-------------------------
The data value could not be converted for reasons other than sign
mismatch
or data overflow. For example, the data was corrupted in the data store but
the row was still retrievable.
Description: An unhandled exception occurred during the execution of
the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidCastException: The data value could
not be
converted for reasons other than sign mismatch or data overflow. For example,
the data was corrupted in the data store but the row was still retrievable.

Source Error:

Line 56: authorisedusernameList.Items.Add( dataReader.GetString( 0 ) );

Source File: c:\inetpub\wwwroot\websupportproject\login.aspx.cs
Line: 56

Stack Trace:
[InvalidCastException: The data value could not be converted for
reasons
other than sign mismatch or data overflow. For example, the data was
corrupted in the data store but the row was still retrievable.]
System.Data.OleDb.DBBindings.get_ValueString()
System.Data.OleDb.OleDbDataReader.GetString(Int32 ordinal)
WebsupportProject.Login.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\websupportproject\login.aspx.cs:56
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
'---------------end of error------------------------------



Thank you for your help so far.
 
Back
Top