How can i record the value once cause it creating multiple record? Database access c# -


else {     connection.open();      oledbcommand command = new oledbcommand();     command.connection = connection;     command.commandtext = "select * tbl_checkins customername='" + textbox1.text + "'and gender ='" + textbox2.text + "'and numberofperson ='" + textbox3.text + "'and address ='" + textbox5.text + "'and contactnumber ='" + textbox6.text + "'and emailaddress ='" + textbox7.text + "'and roomrate ='" + combobox4.text + "'and roomtype ='" + combobox2.text + "'and roomnumber ='" + combobox3.text + "'and checkindate ='" + datepicker.text + "'and checkindate ='" + textbox4.text + "'";     oledbdatareader reader = command.executereader();      int count = 0;     while (reader.read()){         count = count + 1;     }     if (count > 0){         messagebox.show("customer checkin");     }      connection.close();     if (count < 1){         connection.open();          command.commandtext = "insert tbl_checkins ([customername],[gender],[numberofperson],[address],[contactnumber],[emailaddress],[roomrate],[roomtype],[roomnumber],[checkindate],[checkintime]) values('" + textbox1.text + "','" + textbox2.text + "','" + textbox3.text + "','" + textbox5.text + "','" + textbox6.text + "','" + textbox7.text + "','" + combobox4.text + "','" + combobox2.text + "','" + combobox3.text + "','" + datepicker.text + "','" + textbox4.text + "')";         command.executenonquery();         messagebox.show("check in");         connection.close();     } } 

i want display whether customer checked-in or not. however, using above code, duplicate record added database instead of displaying information.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -