Business Object Woes

Hammy

Freshman
Joined
Jan 15, 2003
Messages
27
Location
Ontario, Canada
Hi all,

I am trying to learn how to create/compile to bin/use business objects. However, when I go through the steps as indicated in my book, when I try to access the class created in my (newly compiled) dll file, I get a "object not declared" error.

I have a directory structure as follows....

wwwroot > tyaspnet21days

>BIN
>>tyaspnet21days.dll

>Day15
>>listing1502.aspx

My code to create the dll file is as follows....saved as DataBase.vb
Code:
Imports System
Imports System.Data
Imports System.Data.OleDb

Namespace TYASPNET

   Public Class Database
      public ConnectionString as String
      private objConn as OleDbConnection
      private objCmd as OleDbCommand
      
      public function SelectSQL(strSelect as string) as _
         OleDbDataReader
         try
            objConn = new OleDbConnection(ConnectionString)
            objCmd = new OleDbCommand(strSelect, objConn)
            objCmd.Connection.Open
            return objCmd.ExecuteReader
            objCmd.Connection.Close()
         catch ex as OleDbException
            return nothing
         end try
      end function
      
      public function ExecuteNonQuery(strQuery as string) as _
         Boolean
         try
            objConn = new OleDbConnection(ConnectionString)
            objCmd = new OleDbCommand(strQuery, objConn)
            objCmd.Connection.Open()
            objCmd.ExecuteNonQuery
            objCmd.Connection.Close()
            return true
         catch ex as OleDbException
            return false
         end try
      end function
   End Class
End Namespace

I then compiled it to the bin file of the webroot (not te day15 directory) using the vbc compiler....

vbc/t:library /out:..\bin\tyaspnet21days.dll /r:System.dll /r:System.Data.dll Database.vb

This seems to work nicely, and places the dll file in my bin folder of my webroot.

Then I have a simple page as follows...
Code:
<%@ Page Language="VB" %>

<script runat="server">
   sub Page_Load(obj as object, e as eventargs)
      dim objDatabase as TYASPNET.Database
      lblMessage.Text = "Object created"
   end sub   

</script>

<html><body>
   <asp:Label id="lblMessage" runat="server" />
</body></html>

However, this page will not access the TYASPNET.Database, saying it is not declared. Can anybody please tell me what I am doing wrong?

Thanks so much!
Hammy
 
OK, I copied my bin folder from the webroot to the day15 directory, and it worked. So can I assume that it won't look up the one level to the root for the bin folder?

Hammy
 
Back
Top