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
 
Ad

Advertisements

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
Return Value? 1
Populate TextBox With DB Records 2
Repeatative Code 1
ExecuteScalar? 1
Proxy Class Property? 1
Dynamic Controls 4
DataReader Already Open 2

Top