Здравствуйте подскажите пожалуйста почему в даннном коде программы возникает исключение. Что означает эта ошибка и как её исправить? The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value
| Код |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient;
namespace Turfirma { public partial class Form8 : Form { public Form8() { InitializeComponent(); }
private void Form8_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'turfirmaDataSet.AllZakaziPoTuram' table. You can move, or remove it, as needed. this.zakaziTableAdapter.Fill(this.turfirmaDataSet.Zakazi); }
private void button1_Click(object sender, EventArgs e) { try { string Data_nachala_oformleniya = Convert.ToString(this.maskedTextBox1.Text); string Data_okonchaniya_oformleniya = Convert.ToString(this.maskedTextBox2.Text);
Form1.myConnection = new SqlConnection(); Form1.myConnection.ConnectionString = "Data Source=(local);Initial Catalog=Turfirma;Integrated Security=true;User ID=" + Form1.login + ";Password=" + Form1.pass + ";";
Form1.myConnection.Open();
SqlCommand myCommand = Form1.myConnection.CreateCommand(); myCommand.CommandText = "SELECT * FROM Zakazi WHERE Data_nachala_oformleniya = \'" + Data_nachala_oformleniya + "\'" + " AND Data_okonchaniya_oformleniya = \'" + Data_okonchaniya_oformleniya + "\'"; myCommand.Parameters.Add("@Data_nachala_oformleniya", SqlDbType.DateTime); myCommand.Parameters["@Data_nachala_oformleniya"].Value = Data_nachala_oformleniya; myCommand.Parameters.Add("@Data_okonchaniya_oformleniya", SqlDbType.DateTime); myCommand.Parameters["@Data_okonchaniya_oformleniya"].Value = Data_okonchaniya_oformleniya; myCommand.ExecuteNonQuery(); zakaziTableAdapter.Update(turfirmaDataSet); this.zakaziTableAdapter.Fill(this.turfirmaDataSet.Zakazi); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { Form1.myConnection.Close(); } } } }
|
|