I am building a mock car rental site. I have to check to see if a certain car is reserved or not. I have a table in my SQL database for each car. Each car's table contains a datetime column. Each day a car is reserved an entry is made in said table. Given the users request I know which table to search. My problem is writing a sqlcommand that searches the columns for a specific date time. If it finds nothing then good let us make a reservation, otherwise I cannot make the reservation. to add something to a table this works for me:
cmd = new SqlCommand("INSERT INTO reservationTable (resNumber,pickUp, dropOff) Values(@resNumber,@pickUp,@dropOff)", con);
cmd.Parameters.Add("@resNumber", SqlDbType.Int).Value = i;
cmd.Parameters.Add("@pickUp", SqlDbType.DateTime).Value = reservation.pickUp;
cmd.Parameters.Add("@dropOff", SqlDbType.DateTime).Value = reservation.ret;
cmd.ExecuteNonQuery();
Anyone suggest a search command like this for my intents and purposes? Say for example I wanted to search reservationTable for a specific resNumber.