Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET MySQL MVC
Hello Guys,
morning, i got stuck with of the freaking problem i.e. am using Asp.net 4 (VS 2010) and Mysql(5.5)
for one of My project. created three tables in Mysql and connected it to .Net via server explorer
now i can see those three tables , please note have not written any code till now but as soon as i right click on table name and click refresh suddenly i get a error box saying
"Unable to cast object of type System.DbNull to System.string" and please not the sample DB code how i created my table
 
CREATE TABLE admintable( adminid int NOT NULL primary key,
password varchar(30));
 
here is the image <img src="http://i.imgur.com/cuv0XsY.jpg?1" alt="" title="Hosted by imgur.com" />
this is one table which i have mentioned here, please any out there help me to resolve this as am running out of time please
regards
sam
Posted 21-Apr-13 20:55pm
Comments
Sergey Alexandrovich Kryukov at 22-Apr-13 2:15am
   
Well, who told you that you can case one into another? Check the data for DbNull before casting to anything.
—SA
rmksiva at 22-Apr-13 2:19am
   
May i know, do you want create table by code or using server explorer ?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It is a quite common problem, because DBNull and Null basically mean the same, but are not the same type.
There is a good stackoverflow.com thread[^] which should help you how you can resolve this.
 
cheers,
Marco
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100