大家好,你能帮助我吗,我在将数据插入数据库时遇到问题,我在cmd.executenonquery()行中收到错误说明"数据类型不匹配标准表达式&# 34; ,我需要在代码上更改一些内容吗?
这是我的代码:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim insertI As String = "INSERT INTO Infos (FirstName,SurName,MiddleName,Birthdate,Age,Gender,HomeAddress,CityAddress,BaranggayAddress,TelephoneNumber,EmailAdd1,Birthplace,MobileNumber1,MobileNumber2,Yearlevel,Course,Emailadd2)
VALUES (@FirstName,@SurName,@MiddleName,@Birthdate,@Age,@Gender,@HomeAddress,@CityAddress,@BaranggayAddress,@TelephoneNumber,@EmailAdd1,@Birthplace,@MobileNumber1,@MobileNumber2,@Yearlevel,@Course,@Emailadd2)"
Dim cmd As New OleDbCommand(insertI, con)
'--
cmd.Parameters.AddWithValue("@FirstName", OleDbType.VarWChar)
cmd.Parameters("@FirstName").Value = fname.Text.ToString
'--
cmd.Parameters.AddWithValue("@SurName", OleDbType.VarWChar)
cmd.Parameters("@SurName").Value = Sname.Text.ToString
'--
cmd.Parameters.AddWithValue("@MiddleName", OleDbType.VarWChar)
cmd.Parameters("@MiddleName").Value = Mname.Text.ToString
'--
cmd.Parameters.AddWithValue("@Birthdate", OleDbType.Date)
cmd.Parameters("@Birthdate").Value = Datetxt.Text.ToString
'--
'Domainupdown
cmd.Parameters.AddWithValue("@Age", OleDbType.Integer)
cmd.Parameters("@Age").Value = Agetxt.Text.ToString
'--
'Combobox
cmd.Parameters.AddWithValue("@Gender", OleDbType.VarWChar)
cmd.Parameters("@Gender").Value = gendertxt.Items.ToString
'--
cmd.Parameters.AddWithValue("@HomeAddress", OleDbType.LongVarChar)
cmd.Parameters("@HomeAddress").Value = homaddtxt.Text.ToString
'--
cmd.Parameters.AddWithValue("@CityAddress", OleDbType.VarWChar)
cmd.Parameters("@CityAddress").Value = Cityadd.Text.ToString
'-
cmd.Parameters.AddWithValue("@BaranggayAddress", OleDbType.VarWChar)
cmd.Parameters("@BaranggayAddress").Value = brgyadd.Text.ToString
'--
cmd.Parameters.AddWithValue("@TelephoneNumber", OleDbType.Currency)
cmd.Parameters("@TelephoneNumber").Value = telnumtxt.Text.ToString
'--
cmd.Parameters.AddWithValue("@EmailAdd1", OleDbType.VarWChar)
cmd.Parameters("@EmailAdd1").Value = emailaddtxt.Text.ToString
'--
cmd.Parameters.AddWithValue("@Birthplace", OleDbType.VarWChar)
cmd.Parameters("@Birthplace").Value = birthPtxt.Text.ToString
'--
cmd.Parameters.AddWithValue("@MobileNumber1", OleDbType.Numeric)
cmd.Parameters("@MobileNumber1").Value = mobilenum1txt.Text.ToString
'--
cmd.Parameters.AddWithValue("@MobileNumber2", OleDbType.Numeric)
cmd.Parameters("@MobileNumber1").Value = mobilenum2txt.Text.ToString
'--
'Combobox
cmd.Parameters.AddWithValue("@Yearlevel", OleDbType.VarWChar)
cmd.Parameters("@Yearlevel").Value = Yrlvltxt.Items.ToString
'--
cmd.Parameters.AddWithValue("@Course", OleDbType.VarWChar)
cmd.Parameters("@Course").Value = coursetxt.Text.ToString
'--
cmd.Parameters.AddWithValue("@EmailAdd2", OleDbType.VarWChar)
cmd.Parameters("@EmailAdd2").Value = emailadd2txt.Text.ToString
cmd.ExecuteNonQuery()
con.Close()
End Sub