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:
Edit
After going through your code extensively, which is not shown here there were two areas that were problematic.
One was data annotations and the other was still casting to longint in the xaml.cs
When changing datatypes like this, it can be very fiddly, and we need to go through every file in the code where that field is being handled.
I'm glad you solved your problem, we all understand the frustration of hitting a brick wall :)
It is possible this is being caused by a setting in MSSERVER:
Go to options and untick Prevent saving changes that require table recreation. As you may be appearing to change the table in some parts of your project, but the changes are not being saved in database. So there will be a cast exception, as it is looking for a bigint and not a varchar.