hello,
this is my materiel table :
Materiel(serviceTag varchar(20),
periodeLeasing int,
periodeGarantie int,
idMarque int,
idTypeMateriel int,
idSerieMateriel int,
idEmplacement int,
reparation char(3),
idEntite int,
dateDGarantie dateTime,
dateFGarantie dateTime);
I want to insert a new record using this query
con.charger("insert into Materiel(serviceTag, periodeLeasing, periodeGarantie, idMarque, idTypeMateriel, idSerieMateriel, " +
"idEmplacement, reparation, idEntite, dateDGarantie, dateFGarantie) values ('" + txtServiceTag.Text + "', " + txtPeriodeL.Text + ", " + txtPeriodeG.Text + ", "
+ (cmbMarque.SelectedIndex + 1) + "," + cmbDesignation.SelectedIndex + "," + idSerieMat + ", NULL, NULL, " +
cmbEntite.SelectedIndex + ",'" + Convert.ToDateTime(txtDateD.Text) + "','" + Convert.ToDateTime(txtDateF.Text) + "')", false);
the con is a classe called Connexion, that's where im calling my datasource and datatables / sets / Adapters.
For the asp code, I have a textBox (dateDG and dateFG) with an ajax calendar extender, this is my code
<asp:TextBox ID="txtDateD" runat="server" CssClass="TextBox" Height="25px" AutoPostBack="true"
Width="162px" ontextchanged="txtDateD_TextChanged"></asp:TextBox>
<asp:CalendarExtender ID="txtDateD_CalendarExtender" runat="server"
Enabled="True" TargetControlID="txtDateD" Format="dd/MM/yyyy ">
</asp:CalendarExtender>
When I debug, the query seems to be correct here's an example
insert into Materiel(serviceTag, periodeLeasing, periodeGarantie, idMarque, idTypeMateriel, idSerieMateriel, idEmplacement, reparation, idEntite, dateDGarantie, dateFGarantie) values ('ER65', 12, 12, 1,12,53, NULL, NULL, 3,'08/07/2014 00:00:00','08/07/2015 00:00:00')
but still gives me the same error "The conversion of a varchar data type to a datetime data type resulted in an out-of-range value." Please I need your help