Question

goodevening everyone. I'm working with my codes and encountered this kind of error. How can I eliminate it?? Thanks guys!

enter image description here

Private Sub dgvAttendanceHistoryView()
    Using conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database.accdb;")
        conn.Open()
        Dim command As New OleDbCommand("SELECT sms_text AS ProfID, sent_dt AS [Date/Time] FROM SMS_IN WHERE sms_text='" & dgvAttendanceHistory.CurrentRow.Cells("sms_text").Value & "'", conn)
        Dim adapter As New OleDbDataAdapter
        Dim dt As New DataTable
        adapter.SelectCommand = command
        adapter.Fill(dt)
        dgvAttendanceHistory.DataSource = dt
        setColumnWidth()
    End Using

End Sub

No correct solution

OTHER TIPS

From you comment I can say that either dgvAttendanceHistory.CurrentRow or dgvAttendanceHistory.CurrentRow.Cells("sms_text") is Nothing, so you need to test for that possibility first.

I'd like to point out the fact that you should really be using Parameters in your query instead of concatenating strings, as this opens a door for SQL injection attacks.

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top