DB problem with assemblies

alisrky

New Member
I am trying to create an assembly to make creating a datareader simpler, using just one line of code as follows:<BR><BR><BR>Option Explicit<BR>Option Strict<BR><BR>Imports System.Data<BR>Imports System.Data.SqlClient<BR><BR>Namespace mem_DBtools<BR><BR> Public Class DataReader <BR> <BR> Public Function Open(strSQL as String) as SQLDataReader<BR> Dim strConn as String = ConfigurationSettings.AppSettings("ConnectionString")<BR> Dim objConnection as SQLConnection<BR> objConnection = New SQLConnection(strConn)<BR> objConnection.Open()<BR> <BR> Dim objCommand as SQLCommand<BR> objCommand = New SQLCommand(strSQL, objConnection)<BR> Dim objDataReader as SQLDataReader<BR> Return objCommand.ExecuteReader(CommandBehavior.CloseConn ection)<BR> End Function<BR> <BR> End Class<BR> <BR>End Namespace<BR><BR>I can't get this to compile, instead I get an error with just about every line as follows:<BR><BR>Microsoft (R) Visual Basic .NET Compiler version 7.00.9466<BR>for Microsoft (R) .NET Framework version 1.00.3705.209<BR>Copyright (C) Microsoft Corporation 1987-2001. All rights reserved.<BR><BR>C:dotNetmem_DBtools.vb(4) : error BC30466: Namespace or type 'Data' for the Im<BR>ports 'System.Data' cannot be found.<BR><BR>Imports System.Data<BR> ~~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(5) : error BC30466: Namespace or type 'SqlClient' for the Imports 'System.Data.SqlClient' cannot be found.<BR><BR>Imports System.Data.SqlClient<BR> ~~~~~~~~~~~~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(11) : error BC30002: Type 'SQLDataReader' is not defined.<BR><BR> Public Function Open(strSQL as String) as SQLDataReader<BR> ~~~~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(12) : error BC30451: Name 'ConfigurationSettings' is not declared.<BR><BR> Dim strConn as String = ConfigurationSettings.AppSettings("ConnectionString")<BR> ~~~~~~~~~~~~~~~~~~~~~<BR><BR>C:dotNetmem_DBtools.vb(13) : error BC30002: Type 'SQLConnection' is not defined.<BR><BR> Dim objConnection as SQLConnection<BR> ~~~~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(14) : error BC30002: Type 'SQLConnection' is not defined.<BR><BR> objConnection = New SQLConnection(strConn)<BR> ~~~~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(17) : error BC30002: Type 'SQLCommand' is not defined.<BR><BR> Dim objCommand as SQLCommand<BR> ~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(18) : error BC30002: Type 'SQLCommand' is not defined.<BR><BR> objCommand = New SQLCommand(strSQL, objConnection)<BR> ~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(19) : error BC30002: Type 'SQLDataReader' is not defined.<BR><BR> Dim objDataReader as SQLDataReader<BR> ~~~~~~~~~~~~~<BR>C:dotNetmem_DBtools.vb(20) : error BC30451: Name 'CommandBehavior' is not declared.<BR><BR> Return objCommand.ExecuteReader(CommandBehavior.CloseConn ection)<BR> ~~~~~~~~~~~~~~~<BR><BR>C:DOTNET><BR><BR>Can somebody help me out with this? This is my first attempt at an assembly.I had the same problem and the only way I was able to get it to compile was to include references to System.dll,System.Data.dll, and System.Xml.dll. I was not sure why I needed the reference to System.Xml or why the reference to System.Data.SqlClient did not work at all. I was using the command line compiler, not VS.<BR><BR>vbc /t:library /r:System.dll,System.Data.dll,System.Xml.dll /out:myComponent.dll myComponent.vb<BR><BR>-- Drew
 
Back
Top