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
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