why "import namespace=" ..." if not necessary?

C

Chris

Hi,

1) In file test.aspx, i put:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb"
Inherits="test" %>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.OleDb"%>
....

In file test.aspx.vb, i put:
....
Dim oConnection As System.Data.OleDb.OleDbConnection
....
No problem.It works.
----------------------------
2) But if i put in test.aspx.vb:
....
Dim oConnection As OleDbConnection
....
I get the error: "type OleDbConnection is not defined"
---------------------------
3) if i remove the import lines in test.aspx: and put this in test.aspx.vb:
Dim oConnection As System.Data.OleDb.OleDbConnection
.....

it works too.

So my question: why putting the import namespaces in test.aspx, because in
any way, I have to use "Dim oConnection As
System.Data.OleDb.OleDbConnection" instead of "Dim oConnection As
OleDbConnection" ?

Thanks
Chris









Why then the import in test.aspx?
 
G

Guest

Hi Chris,

If you want to write the script in the same aspx page then the Import
statement is required other wise it's not required.

Hope this is clear.

Balu
 
C

Chris

Hi Balu,

Thanks for replying, but i still don't understand.

In my first file (test.aspx)
----------------------------
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.OleDb"%>

In my second file (test.aspx.vb)
--------------------------------
Dim oConnection As OleDbConnection


This doesn't work.

I have to put:
Dim oConnection As System.Data.OleDb.OleDbConnection
But then, if i remove the import lines from test.aspx, it still works.

So why putting those imports lines?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Import the namespaces in the file where you use them. If you want to use
the namespace in the vb file, import them there:

Imports System.Data
Imports System.Data.OleDb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,082
Latest member
KetonaraKetoACV

Latest Threads

Top