I want to get from the table the receipt number by the product name and the date entered in the datetimepicker
:
string data = Data.Data_ret(ref dateTimePicker1); // получаю дату из datetimepicker string tovarid = Data.QuerysScale("Select NumberOfTovar From Tovar where Name = '" + comboTovarName.Text + "'");// нахожу номер товара по имени из combobox. string check_1 = Data.QuerysScale("Select NumberOfEntrance from Entrance where NumberOfTovar = " + tovarid + " AND Data = " + data + ""); // здесь хочу получить номер поступления по номеру товара и дате.
The code works, but the problem is that check_1
always null
, although the table contains goods receipts with the date I chose. By the way, I applied this query to my database in Access, and it worked fine. What could be the problem?
The method I used to get the date:
static public string Data_ret(ref DateTimePicker dateTimePicker1) { string[] mounth = { "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября","декабря"}; string Data = dateTimePicker1.Text; Data = Data.Remove(Data.Length - 3); int tmp; string day, preMonth; if (int.TryParse(Data.ElementAt(1).ToString(), out tmp)) { day = Data.Substring(0, 2); preMonth = Data.Substring(2, Data.Length - 6).Trim(); } else { day = "0" + Data.ElementAt(0).ToString(); preMonth = Data.Substring(1, Data.Length - 5).Trim(); } string year = Data.Substring(Data.Length - 4); var month = string.Empty; for (int i = 0; i < mounth.Length; i++) { if (preMonth == mounth[i].Trim()) { month = "0" + (i + 1); break; } } var result = string.Concat(day, "/", month, "/", year); return result; }