问题描述
如果operation =new那么
chargementdb()
cmd =新OleDb.OleDbCommand
cmd.CommandText =插入note1(numprof,nummat,nume,noteDT,typenote,dtenote)值(@ numprof,@ nummat,@ nume,@ noteDT,@ typenote,@ dtenote)
cmd.Connection = cnx
cmd.Parameters.AddWithValue(@ numprof,txtidprof.Text)
cmd.Parameters.AddWithValue(@ nummat,combomatiere.Text)
cmd.Parameters.AddWithValue(@ nume,txtmatricule.Text)
cmd.Parameters.AddWithValue(@ noteDT,txtnote.Text)
cmd。 Parameters.AddWithValue(@ typenote,combotyppenote.Text)
cmd.Parameters.AddWithValue(@ dtenote,txtmatricule.Text)
'MsgBox(DateTimePicker1.Value .Date)
'MsgBox(prof& txtidprof.Text)
'MsgBox(matiere& combomatiere.Text)
'MsgBox(matricule& txtmatricule.Text)
'MsgBox(note& txtnote.Text)
'MsgBox(type note& combotyppenote.Text)
'MsgBox(date& txtmatricule.Text)
cmd.ExecuteNonQuery()
我尝试了什么:
我尝试插入表note1 。
If operation = "new" Then
chargementdb()
cmd = New OleDb.OleDbCommand
cmd.CommandText = "insert into note1(numprof,nummat,nume,noteDT,typenote,dtenote)values(@numprof,@nummat,@nume,@noteDT,@typenote,@dtenote)"
cmd.Connection = cnx
cmd.Parameters.AddWithValue("@numprof", txtidprof.Text)
cmd.Parameters.AddWithValue("@nummat", combomatiere.Text)
cmd.Parameters.AddWithValue("@nume", txtmatricule.Text)
cmd.Parameters.AddWithValue("@noteDT", txtnote.Text)
cmd.Parameters.AddWithValue("@typenote", combotyppenote.Text)
cmd.Parameters.AddWithValue("@dtenote", txtmatricule.Text)
' MsgBox(DateTimePicker1.Value.Date)
'MsgBox("prof " & txtidprof.Text)
'MsgBox("matiere " & combomatiere.Text)
'MsgBox("matricule " & txtmatricule.Text)
'MsgBox("note " & txtnote.Text)
'MsgBox("type note " & combotyppenote.Text)
'MsgBox("date " & txtmatricule.Text)
cmd.ExecuteNonQuery()
What I have tried:
I try to insert into a table note1.
推荐答案
Dim dt As DateTime
If Not DateTime.TryParse(txtmatricule.Text, dt) Then
... report problem to user ...
Return
End If
然后将转换后的值作为参数值传递给SQL。
Then pass the converted value to SQL as the parameter value.
这篇关于如何解决此错误“条件表达式中的数据类型不匹配”。 ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!