Understand that English isn’t everyone’s first language so be lenient of bad spelling and grammar. Glad your own solution worked out for you. Member 5-Nov 2: Add your solution here. Please Sign up or sign in to vote. After that, make the necessary conversion to string. Member 5-Nov 3:

That would cause that exception as well. Sign up using Facebook. Sign up or log in Sign up using Google. Now that I know what’s happening I can handle it. You should check reader. Read the question carefully. Glad your own solution worked out for you.

Jon Skeet Jon Skeet k What am I missing? Add ” 3″” Serial No” ; dataGridView1.

Forums – C# Corner

Null value in your data? Check your columns Datatype in DB based on that u should convert when your adding rows in gridview. Also, double-check that the field is really defined as an integer and not, e. Sign up using Email and Password.

Let’s work to help developers, not make them feel stupid. Sign up or log in Sign up using Google.

Spefified Members Sign in to your account. Check that database column is int or not. IsDBNull to detect such rows and act appropriately, e.

If your Cell format is set to General you should change it to Text. Please Sign up or sign in to vote.

  CINEMA GALLIA GENTILLY

GetString 1 I get the same error. Actually i know second method to show from database in dataGridView but my sir wants to show like as dataGridView1. IsDBNull 0 or use following code: Both columns are of type Text.

GetString 0 does it work? Understand that English isn’t everyone’s first language so be lenient of bad spelling and grammar.

c# – data reader specified cast is invalid? – Stack Overflow

Thanks for the help! Specified cast is not valid. By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and datareaded policyand that your continued use of the website is subject to these policies. What’s the type of that column? GetValue instead, what happens?

Glad your own solution worked out for you. GetString method is throwing an exception: After that, make the necessary conversion to specifiec.

Second, you should treat NULL values separately. You getstribg want to modify the query to not include such rows, or use reader. When answering a question please: Ace Troubleshooter Ace Troubleshooter 6 24 Something is wrong with my query, or the way I am processing the results. GetString i ; so how i can there two columns fill completely by this but for third column it shows that error.

Now that I know what’s happening I can handle it. Don’t tell someone to read the manual. Insults are not welcome.

  THAMPURAN MOVIE FEAT JAYALALITHA

[Solved] specified cast is not valid – CodeProject

Member 5-Nov 2: You can try using GetValue instead of GetString. Member 5-Nov 3: Post Your Answer Discard By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyand that your continued use of the website is subject to these policies.

If you were to take the string representation aka epdr[“Entity”]. By using datareaedr site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. It’s like it’s not pulling anything from the database for bas.

specified cast is not valid

Add ” 4″” Enroll Date” ; and my complete code here public partial class frmenrolldetails: What is the actual text being returned in column 1 index 0? This email is in use.

By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyand that your continued use of the website is subject to these policies.