1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Private Sub addtodb()
Dim querytodb As String
querytodb = String.Format("INSERT INTO tblapplicants (program, fname, mname, lname, sex, civilstatus, address, highschoolatt, highschooladd, colunivatt, colunivadd, course, companyname, workexpyrs, degree, birthday, birthplace, nationality, religion, language, mobno, telno, emailadd, yrgraduatedhs, yrgraduatedcoluniv) Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}')", _
programcb.Text, fnametb.Text, mnametb.Text, lnametb.Text, sexcb.Text, cscb.Text, addresstb.Text, hstb.Text, hsatb.Text, cutb.Text, cuatb.Text, coursetb.Text, noctb.Text, yearswecb.Text, degreefcb.Text, bdtp.ToString, birthplacetb.Text, nationalitytb.Text, religiontb.Text, languagetb.Text, mobilenotb.Text, telnotb.Text, eaddtb.Text, graduatedhstb.Text, graduatedcoltb.Text)
Try
conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand(querytodb, conn)
cmd.ExecuteNonQuery()
Catch ex As OleDbException
MsgBox("Database Insertion Error!" + vbNewLine + ex.ToString & vbCrLf, MsgBoxStyle.Critical, Title:="Database Error!")
'error logging
My.Computer.FileSystem.WriteAllText(Application.StartupPath + "_error_log.txt", ex.ToString, True)
'MsgBox("Database Insertion Error!", MsgBoxStyle.Critical, Title:="Database Error!")
Finally
conn.Close()
'MsgBox("Student Successfully Added!")
End Try
End Sub
| |