I have this column ContactNo
and others like this e-g FaxNo
etc.
Problem is in MSSQL these columns were defined as bigint, and I changed them to varchar in MSSQL using Management Studio:
The only reason I want to change it from int to varchar/string so that I can have "0" at start. As in int I can't put "0" in the beginning.
I thought I also need to do change in dataset so I also updated the dataset in WPF. In Data Sets Changed the same column for same table from System.Int64
to System.String
But even I still get this error:
Specified Cast is not valid
It works fine if I change back types to whatever types they were before, but those big int types don't allow zeros.
When I do debugging, see this yellow highlight. After this it directly jumps to exception error:
I suspect you have a field in AgentAccount which you haven't updated to be a string, and it is still an int. As such, the cast is failing. Select AgentAccount in code, hit F12 to jump to the definition, and then update the field to be a string. Then everything should work.
Since you have made changes in the underlying database, all you need to do in your program is regenerate your typed dataset code. That should solve all such issues.
Try this:
Close all the windows and open Dataset1.xsd
(designer). Do something on the designer surface that forces it to regenerate the code. Most of the times just even moving one of the tables a bit should do the trick; but if it doesn't just right-click and add a dummy adapter, then save then delete it and save again. (The intention is to make it regenerate the auto-generated code again).
Repeat the process for any more typed datasets you might have. (I see one named RMSDatabase2Dataset. xsd in the screenshot).
Finally save everything and do a full rebuild of the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With