Ссылка на объект не установлена на экземпляр объекта. Эта ошибка приходит в vb.... помогите мне, пожалуйста
Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 33: End Sub Line 34: Private Sub BindGrid() Line 35: Dim strConnString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString Line 36: Using con As New SqlConnection(strConnString) Line 37: Using cmd As New SqlCommand() Source File: E:\LanguageLab\admin\listeningAplay.aspx.vb Line: 35 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] admin_listeningAplay.BindGrid() in E:\LanguageLab\admin\listeningAplay.aspx.vb:35 admin_listeningAplay.Page_Load(Object sender, EventArgs e) in E:\LanguageLab\admin\listeningAplay.aspx.vb:31 System.Web.UI.Control.OnLoad(EventArgs e) +95 System.Web.UI.Control.LoadRecursive() +59 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1637.0
Что я уже пробовал:
Imports System Imports System.Web Imports System.Data.SqlClient Imports System.Configuration Imports System.IO Partial Class admin_listeningAplay Inherits Page Protected Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click Using br As New BinaryReader(FileUpload1.PostedFile.InputStream) Dim bytes As Byte() = br.ReadBytes(CInt(FileUpload1.PostedFile.InputStream.Length)) Dim strConnString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString Using con As New SqlConnection(strConnString) Using cmd As New SqlCommand() cmd.CommandText = "insert into Audio(Name, ContentType, Data) values (@Name, @ContentType, @Data)" cmd.Parameters.AddWithValue("@Name", Path.GetFileName(FileUpload1.PostedFile.FileName)) cmd.Parameters.AddWithValue("@ContentType", "audio/mpeg3") cmd.Parameters.AddWithValue("@Data", bytes) cmd.Connection = con con.Open() cmd.ExecuteNonQuery() con.Close() End Using End Using End Using Response.Redirect(Request.Url.AbsoluteUri) End Sub Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then BindGrid() End If End Sub Private Sub BindGrid() Dim strConnString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString Using con As New SqlConnection(strConnString) Using cmd As New SqlCommand() cmd.CommandText = "select Id, Name from tblFiles" cmd.Connection = con con.Open() GridView1.DataSource = cmd.ExecuteReader() GridView1.DataBind() con.Close() End Using End Using End Sub End Class