472,787 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,787 software developers and data experts.

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 2221
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vio | last post by:
Hi, I've been trying to embed (statically) wxPy alongside an embedded py interpreter on a linux/gtk box. At one point, for some reason misc.o linking reported "multiple definitions of...
9
by: monkey | last post by:
I just learn to make a blank windows frame with python and wxpython. I found the statment "import wx" cannot work as the original "from wxPython.wx import *". I see in the readme file of wxpython...
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
2
by: Vitali Gontsharuk | last post by:
Hi! I can't find an answer to the following question: does the "import" command in XML Schema import also element declarations? Or only type definitions? As far as I understood, the first takes...
0
by: maxim mat | last post by:
Hi I need to build client for web service. But when I'm using Visual Studio .NET to add Web Reference, I get error: "Custom tool error: Unable to import WebService/Schema. Unable to import...
5
by: mark_galeck_spam_magnet | last post by:
Hi, why does complain name 'compileFile' not defined. But works. Why? (I did read the tutorial, it seems to say "import module" should work. Thank you, Mark
14
by: Paulo da Silva | last post by:
Hi! If I have two files .py such as m.py from c import * ... x=c() ... os.any_method ...
1
by: Eric Hanchrow | last post by:
(This is with Python 2.5.2, on Ubuntu Hardy, if it matters.) This seems so basic that I'm surprised that I didn't find anything about it in the FAQ. (Yes, I am fairly new to Python.) Here are...
3
by: J. Cliff Dyer | last post by:
On Thu, 2008-05-08 at 12:00 -0700, Eric Hanchrow wrote: It's the same reason as this: 5 5 6 5 Python "variables" are just names that point at objects. When you
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.