470,561 Members | 2,307 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,561 developers. It's quick & easy.

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

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?


May 10 '06 #1
3 2112
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

"Chris" wrote:
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?


May 10 '06 #2
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?

"balucris" <ba******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
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

"Chris" wrote:
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?


May 10 '06 #3
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

Chris wrote:
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?

"balucris" <ba******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
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

"Chris" wrote:
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?

May 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Vio | last post: by
9 posts views Thread by monkey | last post: by
2 posts views Thread by Vitali Gontsharuk | last post: by
5 posts views Thread by mark_galeck_spam_magnet | last post: by
14 posts views Thread by Paulo da Silva | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.