troubleshooting Question

How to correct this error in Vb.Net.

Avatar of searchsanjaysharma
searchsanjaysharma asked on
Visual Basic.NET
13 Comments1 Solution314 ViewsLast Modified:
I have a put a time on Vb.NEt windows form, which fethches the data every 15 seconds. but the following error in starting.
Object reference not set to an instance of an object.

Interval - 15000

            If (txtauin.Text.Trim() <> "") Then
                con = New SqlConnection("Data Source=;Initial Catalog=testadms;User Id=sa;Password=admin#cgc;")
                s1 = "select isnull(flagah,0),isnull(flagf,0),isnull(flagr,0) from mststudents where uin ='" & txtauin.Text.Trim() & "' and sname is not null"
                If (con.State = ConnectionState.Closed) Then
                End If
                da1 = New SqlDataAdapter(s1, con)
                dt1 = New DataTable
                If (dt1.Rows.Count = 0) Then
                    MessageBox.Show("No Record Found")
                    txtauin.Text = ""
                    If (Convert.ToInt32(dt1.Rows(0)(0).ToString()) = 1) Then
                        btnah.BackColor = Color.Green
                        btnah.Visible = True

                        btnah.BackColor = Color.Red
                        btnah.Visible = True

                    End If
                    If (Convert.ToInt32(dt1.Rows(0)(1).ToString()) = 1) Then
                        btnf.BackColor = Color.Green
                        btnf.Visible = True
                        btnf.BackColor = Color.Red
                        btnf.Visible = True
                    End If
                    If (Convert.ToInt32(dt1.Rows(0)(2).ToString()) = 1) Then
                        btnr.BackColor = Color.Green
                        btnr.Visible = True
                        btnr.BackColor = Color.Red
                        btnr.Visible = True
                    End If
                End If
            End If
        Catch ex As Exception
            MsgBox("Error Occurred " + ex.ToString())
            If ConnectionState.Open Then
            End If
        End Try
Dirk Haest
Project manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros