שאילתת SQL
זה הקטע קוד שלי:
זה הקטע קוד שלי:
string val = list_of_flights_on_that_date.Items[list_of_flights_on_that_date.SelectedIndex].Value; //split the text item to retrieve the ID and Date string[] str = val.Split(new char[] {'-'},4); string[] str1 = str[0].Split(new char[] {':'},2); string[] str2 = str[1].Split(new char[] {':'},2); conn.Open(); SqlCommand cmd_id; cmd_id = new SqlCommand("select Estimated_Num_Of_Pass from Flight_Plan where Flight_Id = @id", conn); // and Flight_Date = @date cmd_id.Parameters.Add(new SqlParameter("@id",SqlDbType.Int,4)); cmd_id.Parameters["@id"].Value=str1[1]; cmd_id.Parameters.Add(new SqlParameter("@date",SqlDbType.DateTime,8)); cmd_id.Parameters["@date"].Value=Convert.ToDateTime(str2[1]).ToShortDateString(); TotalBox.Text=cmd_id.ExecuteReader().ToString();
זה מופעל מתוך listbox וכשאני לוחץ על אחץ הרשומות שמתקבלות אמור להתקבל מספר לתוך תיבת הטקסט TotalBox, אבל במקום אני מקבל את השגיאה הבאה:System.FormatException: Input string was not in a correct format.
מישהו יכול לומר לי איפה הבעיה? בדקתי את השאילתא ב Query analyzer וזה עבד..