Namespace Not Found?

A

Arpan

I successfully compiled a "Database.vb" file (existing in
C:\Inetpub\wwwroot\ASPX\Business) into "Database.dll" (in
C:\Inetpub\wwwroot\ASPX\bin). The namespace in "Database.vb" is
"Database" which encapsulates a class named "DBSettings". This is the
code in "Database.vb":

Imports System
Imports System.Data
Imports System.Data.SqlClient

Namespace Database
Public Class DBSettings
Private sqlCmd As SqlCommand
Private sqlConn As SqlConnection
Public ConnectionString As String

Public Function QueryDB(ByVal qry As String) As SqlDataReader
sqlConn = New SqlConnection(ConnectionString)
sqlCmd = New SqlCommand(qry, sqlConn)

sqlConn.Open()
Return sqlCmd.ExecuteReader

sqlConn.Close()
End Function
End Class
End Namespace

To use the above namespace in a class file named "Users.vb" (which
exists in the same folder as "Database.vb"), I am using the following
code:

Imports Database

Namespace Users
Public Class User
Public Function Login(ByVal UserName As String, ByVal Password
As String) As Integer
Dim iID As Integer
Dim boDBSet As DBSettings
Dim sqlReader As SqlDataReader

boDBSet = New DBSettings
boDBSet.ConnectionString = "Data Source=......."
sqlReader = boDBSet.QueryDB("SELECT ID FROM tblUsers WHERE
UserName='" & UserName & "' AND Password='" & Password & "'")

Do While (sqlReader.Read)
iID = sqlReader.GetInt32(0)
Loop

Return iID
End Function
End Class
End Namespace

But when I try to compile the above code into "Users.dll" (in the same
folder where "Database.dll" exists) from the command prompt, the
following errors gets generated:

Namespace or type specified in the Imports 'Database' doesn't contain
any public member or cannot be found. Make sure the namespace or the
type is defined and contains at least one public member.

Type 'DBSettings' is not defined.

which points to the following 2 lines

Dim boDBSet As DBSettings
boDBSet = New DBSettings

What am I doing wrong here?

Thanks,

Arpan
 
H

Hans Kesting

I successfully compiled a "Database.vb" file (existing in
C:\Inetpub\wwwroot\ASPX\Business) into "Database.dll" (in
C:\Inetpub\wwwroot\ASPX\bin). The namespace in "Database.vb" is
"Database" which encapsulates a class named "DBSettings". This is the
code in "Database.vb":
[snip]
But when I try to compile the above code into "Users.dll" (in the same
folder where "Database.dll" exists) from the command prompt, the
following errors gets generated:

Namespace or type specified in the Imports 'Database' doesn't contain
any public member or cannot be found. Make sure the namespace or the
type is defined and contains at least one public member.

Type 'DBSettings' is not defined.

which points to the following 2 lines

Dim boDBSet As DBSettings
boDBSet = New DBSettings

What am I doing wrong here?

Thanks,

Arpan

The "Imports" statement ("using" in C#) doesn't "do" anything. It
doesn't provide a link to a dll, it just enables the programmer to
leave out the namespaces.
I think you need to find a switch for that command-line compiler (maybe
\r ?) that enables you to specify dll's to be referenced.

Hans Kesting
 

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

Similar Threads

Interface 13
Proxy Class Property? 1
IHttpModule type not found? 1
Dynamic Controls 4
Return Value? 1
Using WebService In ASPX 2
ExecuteScalar? 1
Show "No Records Found" Message 1

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,125
Members
46,706
Latest member
liammiller

Latest Threads

Top