Hi , i'm developing a form to insert data in the Database (SQlServer 2005) i use Linq to Sql in WPF;
I have this database :
Column Name Data Type Allow Null
CODE ID Int(autoIncr) No
BoatName Nvarchar(100) No
BoatType Nvarchar(50) yes
NumberOfSeats Int yes
And so on...
Now when i insert a new record in my form if i leave empty the TextBox "txtNumberOfSeats" that refer to field "NumberOfSeat" in the database and when i click the button Save the database give me this error:"Input string was not in a correct format."
Why i cannot leave the field "NumberOfSeats " empty if i set up it in database AllowNull=Yes?
i post the code behind when i click the button Save to insert to new record in the database:
DataClassesDataContext dc = new DataClassesDataContext();
Boat_TBL boat = new Boat_TBL();
boat.BoatName = txtBoatName.Text;
boat.BoatType = txtBoatType.Text;
boat.NumberOfSeats = Int32.Parse(txtNumberOfSeats.Text);
dc.Boat_TBLs.InsertOnSubmit(boat);
dc.SubmitChanges;
DO you have any suggestion to work out this feature?
Thanks so much
Cheers