Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim insertOk As Boolean = True
Dim con1 As OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand
Dim query As String
Dim temp As Integer
con1 = New OleDb.OleDbConnection("Provider=MSDAORA.1;Data Source=localhost;Persist Security Info=True;Password=sys;User ID=nitishok")
con1.Open()
query = "insert into APPLICANTS(APPLICANT_ID,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SEX,F_H,TOWN,TALUKA,DISTRICT,LANDLINE,MOBILE,BLOOD_GROUP,EDU,DOB) values(:aid,:fn,:mn,:ln,:s,:fh,:tw,:tl,:ds,:land,:mob,:bg,:edu,:dob)"
cmd = New OleDb.OleDbCommand(query, con1)
cmd.Parameters.Add(":aid", OleDb.OleDbType.VarChar).Value = TextBox7.Text
cmd.Parameters.Add(":fn", OleDb.OleDbType.LongVarChar).Value = TextBox1.Text
cmd.Parameters.Add(":mn", OleDb.OleDbType.LongVarChar).Value = TextBox12.Text
cmd.Parameters.Add(":ln", OleDb.OleDbType.LongVarChar).Value = TextBox11.Text
cmd.Parameters.Add(":s", OleDb.OleDbType.LongVarChar).Value = ComboBox1.Text
cmd.Parameters.Add(":fh", OleDb.OleDbType.LongVarChar).Value = TextBox2.Text
cmd.Parameters.Add(":tw", OleDb.OleDbType.LongVarChar).Value = TextBox10.Text
cmd.Parameters.Add(":tl", OleDb.OleDbType.LongVarChar).Value = TextBox8.Text
cmd.Parameters.Add(":ds", OleDb.OleDbType.LongVarChar).Value = TextBox9.Text
cmd.Parameters.Add(":land", OleDb.OleDbType.LongVarChar).Value = TextBox5.Text
cmd.Parameters.Add(":mob", OleDb.OleDbType.LongVarChar).Value = TextBox6.Text
cmd.Parameters.Add(":bg", OleDb.OleDbType.LongVarChar).Value = ComboBox2.Text
cmd.Parameters.Add(":edu", OleDb.OleDbType.LongVarChar).Value = TextBox4.Text
cmd.Parameters.Add(":dob", OleDb.OleDbType.Date).Value = DateTimePicker1.Value
cmd.CommandType = CommandType.Text
temp = cmd.ExecuteNonQuery()
If temp > 0 Then
MessageBox.Show("Record Added!")
Else
MessageBox.Show("Record Not Added!")
End If
con1.Close()
End Sub
我对 vb .net 完全陌生。我为我的学期工作做了一个简单的项目。
请向我解释如何插入值。
我得到这个错误 ORA-01008: not all variables bound....
我正在使用 vb.net VS 2008 oracle 数据库 oledb 连接