Dim valcommande, client, tissu, nometape, nommachine, valcoloris, valsaison As String Dim numetape As String Dim commentaire As String client = ComboBox2.Text 'combobox2 est liée à une autre table du base de données et il est de type texte valcommande = TextBox3.Text tissu = TextBox4.Text Dim datecreation = DateTimePicker1.Text valcoloris = TextBox36.Text valsaison = TextBox37.Text commentaire = RichTextBox1.Text 'ETAPE 1 If TextBox3.Text "" Or TextBox4.Text "" Or ComboBox2.Text = "" Or ComboBox1.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or TextBox5.Text = "" Then MsgBox("Il faut remplir tous les champs") Else 'les instructions Dim valprod1, valconcentration1 As String Dim valprod2, valconcentration2 As String Dim valprod3, valconcentration3 As String Dim valtemp, valeau, valtemperature As String Dim ds As New DataSet numetape = CStr(TextBox2.Text) nometape = ComboBox1.Text 'combobox1 est liée à une autre table du base de données et il est de type texte nommachine = ComboBox3.Text 'combobox3 est liée à une autre table du base de données et il est de type texte valtemp = CStr(NumericUpDown1.Value) valeau = CStr(NumericUpDown2.Value) valtemperature = CStr(NumericUpDown3.Value) valprod1 = ComboBox4.Text 'combobox4 est liée à une autre table du base de données et il est de type texte valconcentration1 = TextBox5.Text valprod2 = ComboBox5.Text 'combobox5 est liée à une autre table du base de données et il est de type texte valconcentration2 = TextBox6.Text valprod3 = ComboBox6.Text ''combobox6 est liée à une autre table du base de données et il est de type texte valconcentration3 = TextBox7.Text Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = K:\edition des cycles\WindowsApplication1\Editiondescycle.mdb" Dim Mycommand As OleDbCommand = con.CreateCommand() Mycommand.CommandText = "INSERT INTO Fichetraitement(Commande, Client, Tissu, [Num etape], Etape, Machine, Temp, Eau, [Température], [Produit1], [Concentration1], [Produit2], [Concentration2], [Produit3], [Concentration3], Commentaire, Coloris, Saison, [Dtae creation]) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" Mycommand.Parameters.Add("valcommande", OleDbType.BSTR).Value = TextBox3.Text Mycommand.Parameters.Add("client", OleDbType.BSTR).Value = ComboBox2.Text Mycommand.Parameters.Add("tissu", OleDbType.BSTR).Value = TextBox4.Text Mycommand.Parameters.Add("numetape", OleDbType.BSTR).Value = TextBox2.Text Mycommand.Parameters.Add("nometape", OleDbType.BSTR).Value = ComboBox1.Text Mycommand.Parameters.Add("nommachine", OleDbType.BSTR).Value = ComboBox3.Text Mycommand.Parameters.Add("valtemp", OleDbType.BSTR).Value = NumericUpDown1.Value.ToString Mycommand.Parameters.Add("valeau", OleDbType.BSTR).Value = NumericUpDown2.Value.ToString Mycommand.Parameters.Add("valtemperature", OleDbType.BSTR).Value = NumericUpDown3.Value.ToString Mycommand.Parameters.Add("valprod1", OleDbType.BSTR).Value = ComboBox4.Text Mycommand.Parameters.Add("valconcentration1", OleDbType.BSTR).Value = TextBox5.Text Mycommand.Parameters.Add("valprod2", OleDbType.BSTR).Value = ComboBox5.Text Mycommand.Parameters.Add("valconcentration2", OleDbType.BSTR).Value = TextBox6.Text Mycommand.Parameters.Add("valprod3", OleDbType.BSTR).Value = ComboBox6.Text Mycommand.Parameters.Add("valconcentration3", OleDbType.BSTR).Value = TextBox7.Text Mycommand.Parameters.Add("commentaire", OleDbType.BSTR).Value = RichTextBox1.Text Mycommand.Parameters.Add("valcoloris", OleDbType.BSTR).Value = TextBox36.Text Mycommand.Parameters.Add("valsaison", OleDbType.BSTR).Value = TextBox37.Text Mycommand.Parameters.Add("datecreation", OleDbType.BSTR).Value = datecreation.ToString con.Open() Dim myReader As OleDbDataReader = Mycommand.ExecuteReader() myReader.Close() con.Close() End If
h = NumericUpDown1.Value i = NumericUpDown2.Value j = NumericUpDown3.Value
dim r as date
Dim r As Date
Mycommand.Parameters.AddWithValue("r", CDate(DateTimePicker1.Text))
Mycommand.Parameters.AddWithValue("r", CDate(DateTimePicker1.Text))
Mycommand.Parameters.AddWithValue("r", "chaine_de_caractères"
Dim valcommande, client, tissu, nometape, nommachine, valcoloris, valsaison As String Dim datecreation As Date Dim numetape As Integer Dim commentaire As String client = ComboBox2.Text 'combobox2 est liée à une autre table du base de données et il est de type texte valcommande = TextBox3.Text tissu = TextBox4.Text datecreation = DateTimePicker1.Value valcoloris = TextBox36.Text valsaison = TextBox37.Text commentaire = RichTextBox1.Text 'ETAPE 1 If TextBox3.Text "" Or TextBox4.Text "" Or ComboBox2.Text = "" Or ComboBox1.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or TextBox5.Text = "" Then MsgBox("Il faut remplir tous les champs") Else 'les instructions Dim valprod1, valconcentration1 As String Dim valprod2, valconcentration2 As String Dim valprod3, valconcentration3 As String Dim valtemp, valeau, valtemperature As Integer Dim ds As New DataSet numetape = CInt(TextBox2.Text) nometape = ComboBox1.Text 'combobox1 est liée à une autre table du base de données et il est de type texte nommachine = ComboBox3.Text 'combobox3 est liée à une autre table du base de données et il est de type texte valtemp = CInt(NumericUpDown1.Value) valeau = CInt(NumericUpDown2.Value) valtemperature = CInt(NumericUpDown3.Value) valprod1 = ComboBox4.Text 'combobox4 est liée à une autre table du base de données et il est de type texte valconcentration1 = TextBox5.Text valprod2 = ComboBox5.Text 'combobox5 est liée à une autre table du base de données et il est de type texte valconcentration2 = TextBox6.Text valprod3 = ComboBox6.Text ''combobox6 est liée à une autre table du base de données et il est de type texte valconcentration3 = TextBox7.Text Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = F:\edition des cycles\WindowsApplication1\Editiondescycle.mdb" Dim Mycommand As OleDbCommand = con.CreateCommand() Mycommand.CommandText = "INSERT INTO Fichetraitement(Commande, Client, Tissu, [Num etape], Etape, Machine, Temp, Eau, [Température], [Produit1], [Concentration1], [Produit2], [Concentration2], [Produit3], [Concentration3], Commentaire, Coloris, Saison, [Dtae creation]) VALUES ('valcommande','client','tissu',numetape,'nometape','nommachine',valtemp,valeau,valtemperature,'valprod1','valconcentration1','valprod2','valconcentration2','valprod3','valconcentration3','commentaire','valcoloris','valsaison',#datecreation#)" Mycommand.Parameters.AddWithValue("valcommande", TextBox3.Text) Mycommand.Parameters.AddWithValue("client", ComboBox2.Text) Mycommand.Parameters.AddWithValue("tissu", TextBox4.Text) Mycommand.Parameters.AddWithValue("numetape", TextBox2.Text) Mycommand.Parameters.AddWithValue("nometape", ComboBox1.Text) Mycommand.Parameters.AddWithValue("nommachine", ComboBox3.Text) Mycommand.Parameters.AddWithValue("valtemp", NumericUpDown1.Value) Mycommand.Parameters.AddWithValue("valeau", NumericUpDown2.Value) Mycommand.Parameters.AddWithValue("valtemperature", NumericUpDown3.Value) Mycommand.Parameters.AddWithValue("valprod1", ComboBox4.Text) Mycommand.Parameters.AddWithValue("valconcentration1", TextBox5.Text) Mycommand.Parameters.AddWithValue("valprod2", ComboBox5.Text) Mycommand.Parameters.AddWithValue("valconcentration2", TextBox6.Text) Mycommand.Parameters.AddWithValue("valprod3", ComboBox6.Text) Mycommand.Parameters.AddWithValue("valconcentration3", TextBox7.Text) Mycommand.Parameters.AddWithValue("commentaire", RichTextBox1.Text) Mycommand.Parameters.AddWithValue("valcoloris", TextBox36.Text) Mycommand.Parameters.AddWithValue("valsaison", TextBox37.Text) Mycommand.Parameters.AddWithValue("datecreation", DateTimePicker1.Value) con.Open() Dim myReader As OleDbDataReader = Mycommand.ExecuteReader() myReader.Close() con.Close() End If
Mycommand.Parameters.AddWithValue("r", CDate(DateTimePicker1.Text))
Mycommand.Parameters.AddWithValue("r", CDate(DateTimePicker1.Text))
dim unedate as date unedate = CDate(DateTimePicker1.Text) Mycommand.Parameters.AddWithValue("r", unedate)
Mycommand.Parameters.AddWithValue("datecreation", DateTimePicker1.Text)= 15/04/2012 20:39:04
datecreation = CDate(DateTimePicker1.Text) dim unedate as date date = datecreation . . . Mycommand.Parameters.AddWithValue("datecreation", unedate)
Reste que chaine_de_caractères devrait avoir le fon format (celui attendu par le champ d'accueil). Il suffit alors, en cas de besoin, d'appliquer Format à DateTimePicker1.Text.