0

I have seen the question posed on this link but it doesn't solve my problem

This is my code:

Private Sub BindGrid()
    Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString


    Dim query As String = "SELECT ContactName,REF,BRANCH,AMT_ON  FROM dbo.dispatchedbranches where ref=@ref or @ref=''"
    Dim cmd As New sqlcommand(query)
    cmd.Parameters.AddWithValue("@ref", TextBox1.Text)
    Using con As New SqlConnection(conString)
        Using sda As New SqlDataAdapter()
            cmd.Connection = con
            sda.SelectCommand = cmd
            Using ds As New DataSet()
                sda.Fill(ds)
                gvCustomers.DataSource = ds
                gvCustomers.DataBind()
            End Using
        End Using
    End Using
End Sub

End Class

; I tried this solution but it is not working : see link to a probable solution NullReferenceExecption was unhandled by User code error while connecting Sql Local db using vb.net in visual studio 2013

Community
  • 1
  • 1
Mr Brown
  • 3
  • 1
  • Please tell me what line it throws this exception on. – Sasha Apr 04 '17 at 14:36
  • The answer on your liked post should fix the problem. Are you doing it right? There should be an `app.config` file in your project which has the connection string. In there you will see the `name` tag and it's that you should be referencing. – Bugs Apr 04 '17 at 14:45

0 Answers0