cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Steve\Documents\Visual Studio 2010\Projects\Church Of Glory\Church Of Glory\Registry.accdb"
cmd.CommandText = "update Registry set relaship = '" + ComboBox3.Text + "',fathnam = '" + fathnam.Text + "',dob = '" & DateTimePicker1.Value & "',age = '" + age.Text + "',addr = '" + addr.Text + "',area = '" + areas.Text + "',city = '" + city.Text + "',zipc = '" + pinc.Text + "',conta = '" + cnct.Text + "',email = '" + email.Text + "',occup = '" + occu.Text + "',bap_stat = '" + bap_stat + "',bap_dat = '" & DateTimePicker2.Value & "',mar_stat = '" + mar_stat + "',mar_dat = '" & DateTimePicker3.Value & "',gen = 'Male' where fnam = '" + ComboBox2.Text + "' and lnam = '" + ComboBox1.Text + "'"
cmd.Connection = cn
cn.Open()
cmd.ExecuteNonQuery()
MsgBox("Update Successful")
cn.Close()
此代码在我的系统中完美运行.. 但它说
oledb 异常未处理“数据类型不匹配”
当我复制代码并在我兄弟的计算机上执行它时..我小心地更改了数据源路径...我只是一个初学者..所有字段类型都是文本,除了日期..我还有一个字段是一个自动编号,我不想在我的更新查询中使用它..所以我离开了它..