I’m facing a problem regarding database and combo box. I got a table name “station” and inside the table are columns, station name and seats. The column seats are set as “BIT”. I use a combo box for user to select ‘Yes’ or ‘No’ but how to convert them to BIT and store into database. This is my codes for the create.
private void btnCreate_Click(object sender, EventArgs e)
{
using (testEntities Setupctx = new testEntities())
{
string[] stations = StationNameList();
station creStation = new station();
creStation.Station1 = txtStation.Text;
creStation.Seat = cbSeats.SelectedItem();
if (stations.Contains(txtStation.Text))
{
MessageBox.Show("This Station is already been created. Please enter a new Station.");
}
else
{
Setupctx.stations.AddObject(creStation);
Setupctx.SaveChanges();
txtStation.Text = "";
cbSeats.SelectedIndex = -1;
MessageBox.Show("New Station Has Been Created.");
}
}
}
The error is at here:
creStation.Seat = cbSeats.SelectedItem();
They prompt me cannot convert from string to bool.
Any help?
same as