I haven’t used .Net since 2005, so I copied the ADO sample code from Microsoft (which is shoddy at best), and got a Compilation Error at line 1:
ASPNET: Make sure that the class defined in this code file matches the
‘inherits’ attribute, and that it extends the correct base class (e.g.
Page or UserControl).
Line 1: using System;
Line 2: using System.Data;
Line 3: using System.Data.SqlClient;
I put the sample code in a .aspx.cs file. Was I supposed to declare something before the using …?
The problem appears to be that the MSDN code sample you’re using wasn’t prepared for use in a web page. Classes defined in a code behind should inherit from
PageorUserControland the Console application example from MSDN doesn’t do either.Perhaps one of the ASP.NET tutorials would provide a better example.