error of oledbexception was unhandled

bantony02

New member
Joined
Mar 24, 2011
Messages
1
Programming Experience
Beginner
VB.NET:
        Dim name As String = txtFNS.Text + txtLNS.Text
        Dim coursename As String = vbNullString
        If rbnIJ.Checked = True Then
            coursename = rbnIJ.Text
        ElseIf rbnDC.Checked = True Then
            coursename = rbnDC.Text
        ElseIf rbnOCour.Checked = True Then
            coursename = rbnOCour.Text
        ElseIf rbnSAP.Checked = True Then
            coursename = rbnSAP.Text
        ElseIf rbnHKC.Checked = True Then
            coursename = rbnHKC.Text
        End If
        Dim Age As String = nudAge.Value
        Dim Gender As String = cbxGen.Text
        Dim Country As String = txtCoun.Text
        Dim Identity As String = txtIIDS.Text
        Dim Mother As String = txtMT.Text
        Dim Address As String = txtADDS.Text
        Dim Phone As Integer = txtMPS.Text
        Dim Email As String = txtEmS.Text
        Dim Facebook As String = txtFBS.Text
        Dim Msn As String = txtMSNS.Text
        Dim Job As String = txtJobS.Text
        Dim CourseN As String = coursename
        Dim StudyAbroad As Boolean = rbnSAP.Checked
        Dim PaymentTerm As Integer = nudPayTerm.Value
        Dim FeePaid As Boolean = cbxPaid.Checked
        Dim ApplyTime As Date = Date.Today
        Dim Accommodation As String = cbxAWS.Text
        Dim PaymentMethod As String = clbPayment.SelectedItem
        Dim sqlStr As String = "select * from Student order by StudentID desc;"
        Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
        dataAdapter.Fill(dbt)
        dataAdapter.Dispose()
        If dbt.Rows.Count = 0 Then
            StudentIDs = 1
        Else
            StudentIDs = dbt(0)("StudentID")
            StudentIDs = StudentIDs + 1
        End If
        sqlStr = "insert into Student values(" & StudentIDs & ",'" & name & "'," & Age & ",'" & Gender &
            "','" & Country & "','" & Identity & "','" & Mother & "','" & Address & "'," & Phone & ",'" & Email &
            "','" & Facebook & "','" & Msn & "','" & Job & "','" & CourseN & "','" & StudyAbroad & "'," & PaymentTerm &
            "," & "'" & FeePaid & "','#" & ApplyTime & "#'," & 1 & ",'adad','" & Accommodation & "','" & PaymentMethod & "'," & 0 & "," & 0 & ");"
        Dim dataAdapter1 As New OleDb.OleDbDataAdapter(sqlStr, connStr)
        dataAdapter1.Fill(dbt) <<------oledbexception was unhandled !
        dataAdapter.Dispose()

insert into Student values(103,'firname',15,'Female','Country','R14124124','English','xxxxxxxxxxxxxxxxxxxxxxxxxx',1241241,'bbb@yahoo.com','bbb@yahoo.com','bbb@yahoo.com','noe','Study Abroad Programs','True',16,'True','24/3/2011',1,'adad','Private Hostels','Master',0,0);

Please help me to fix this,,i have no idea on this error, I had tried to insert the data in microsoft access directly,it works and has no error!

thanks
 
One of the regulars here, John McIlhinney, will no doubt point you to the very useful Using Parameters in ADO.NET that he has penned on his blog (check the August archive on the right)

Armed with that, you can clear up that 'hectic' SQL string to something you can easily debug.
 
Back
Top