Reputation: 617
I'm planning to utilize the global import for System.Data package. After I added the
<%@ Import Namespace="System.Data" %>
in the markup of global.asax
In one of my class I removed 'Using System.Data' on top of the code. I built the global.asax and the class.
But instead of built successful, I received error
The name 'CommandType' does not exist in the current context.
Upvotes: 2
Views: 3311
Reputation: 46047
I think you might need to import the System.Data.SqlClient
namespace too, assuming that's a command object it's failing on.
EDIT
If you want certain namespaces available to all pages, try adding them in the web.config instead:
<pages>
<namespaces>
<add namespace="System.IO" />
<add namespace="ProjectName.Classes" />
</namespaces>
</pages>
Upvotes: 1
Reputation: 25197
I think that you misunderstand what global.asax does.
It doesn't provide for global Import/Using statements.
Read up on it here and even better a Stackoverflow answer here
Global.asax allows you to handle application/session lifecyle events.
You will need to include your Import Namespace in the files that you are using calls to the System.Data namespace
Upvotes: 2