Error: System.NullReferenceException Object reference not set to an instance of an object when connection string not defined in ASP.Net

Last Reply on Jan 30, 2017 04:59 AM By AnandM

Posted on Jan 29, 2017 09:31 PM

Hello.  I am requesting assistance to actually run the examples shown at .

My code is supposed to ASP.NET, VB.NET compliant.

My situation is almost exactly the same as the example there.  Need to upload some (.pdf) files (say smaller than 100kB each), then store each in varbinary(max?) field in SQL Server 2008 R2 database, then make them available for viewing later in HTML Browser (preferably each in its own page).

When I tried to actually run the html provided, I got the following error:

Compiler Error Message: BC30456: 'Upload' is not a member of 'ASP.pdf_sql_server_aspx'.

Source Error:

Line 17: <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="Upload" />

Appreciate any help provided.

Posted on Jan 30, 2017 04:59 AM
kennr says:
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString

 You need to set the connection string in configuration section of your web.config like below

    <add name ="constr" connectionString="Server=xxxxx;DataBase=Test;UID=xxx;PWD=xxxx" providerName="System.Data.SqlClient" />