I want to insert data into my table Shelter from a form (with TextBox, DateTimePicker, Image, comboBox ...). However, my code returns me different errors.
Description of my table Shelter
Code:
Code int 4 Primary key
Category nvarchar 50
Name nvarchar 50
NbOfAdult nvarchar 2
NbOfKid nvarchar 2
RateOfTVA nvarchar 10
PriceTTC int 4
Picture image
DateCreated datetime
DateModified datetime
ModifiedBy nvarchar 50
Here is my code:
Code:
private void btnOK_Click(object sender, EventArgs e)
{
dbShelterDataSet1.ShelterRow newShelterRow = dbShelterDataSet1.Shelter.NewShelterRow();
newShelterRow.Code = Int32.Parse(tbReference.Text);
newShelterRow.Category = cbCategory.Text;
newShelterRow.Name = tbNameShelter.Text;
newShelterRow.NbOfAdult = Int32.Parse(mtbNbOfAdult.Text);
newShelterRow.NbOfKid = Int32.Parse(mtbNbOfKid.Text);
newShelterRow.RateOfTVA = Int32.Parse(cbRateOfTVA.Text);
newShelterRow.PriceTTC = Int32.Parse(tbLowSeasonWeekPriceTTC.Text);
newShelterRow.Picture = t***ctures.Text;
newShelterRow.DateCreated = dtpDateCreated.Text;
newShelterRow.DateModified = dtpDateModified.Text;
newShelterRow.ModifiedBy = cbModifiedBy.Text;
dbShelterDataSet1.Shelter.AddShelterRow(newShelterRow);
try
{
shelterTableAdapter.Update(dbShelterDataSet1.Shelter);
}
catch (SqlCeException exception)
{
MessageBox.Show("Error :\n" + exception.Message, "Error");
}
}
I have the following errors:
Code:
newShelterRow.Picture = t***ctures.Text;
gives
Can not implicitly convert type 'string' to 'byte []'
Code:
newShelterRow.DateCreated = dtpDateCreated.Text;
gives
Can not implicitly convert type 'string' to 'System.DateTime'
Code:
newShelterRow.DateModified = dtpDateModified.Text;
gives
Can not implicitly convert type 'string' to 'System.DateTime'
Bookmarks