đạt nguyễn
đạt nguyễn

Reputation: 19

Column ... does not belong to table?

I'm making a application coffee shop management in C#.

I have tables like Bill, BillInfo, Food, FoodCategory, FoodTable and I have 10 FoodTables.

When I click one of the tables then an error occurs

Column 'DateCheckIn' does not belong to table

My code:

//my data
insert Bill(DateCheckIn, DateCheckOut, idTable, status) 
values (GETDATE(), NULL, 1, 0); 
insert Bill(DateCheckIn, DateCheckOut, idTable, status) 
values (GETDATE(), NULL, 2, 0); 
insert Bill(DateCheckIn, DateCheckOut, idTable, status) 
values (GETDATE(), GETDATE(), 2, 1); 

//my code
public Bill(DataRow row)
{
        this.ID = (int)row["id"];
        this.DateCheckIn = (DateTime?)row["DateCheckIn"];

        var dateCheckOutTemp = row["DateCheckOut"];

        if(dateCheckOutTemp.ToString() != "")
            this.DateCheckOut = (DateTime?)dateCheckOutTemp;

        this.Status = (int)row["status"];
}

Upvotes: 1

Views: 762

Answers (1)

you have to add the required column to your Table.

Alter table <TableName> 
add <columnName> <columnType>

Upvotes: 1

Related Questions