BOOK: Professional ASP.NET 1.0, Special Edition/1.1
This is the forum to discuss the Wrox book Professional ASP.NET 1.1 by Alex Homer, Dave Sussman, Rob Howard, Brian Francis, Karli Watson, Richard Anderson; ISBN: 9780764558900
You are currently viewing the BOOK: Professional ASP.NET 1.0, Special Edition/1.1 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Hello,
I am Noman and reader of your books. I have a problem about the
compilation of VB source files.
As I was reading the section “ Using Code Behind” on page number 166 in your book named “Professional ASP.NET” ,All thing were right but when I compiled the following file then compiler showed me an error that
“File that raise the compiler errors
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Reflection
Namespace DataLayer
public class DataObj
private _connStr as string
public sub New()
MyBase.new()
_connstr=""
end sub
public sub New(ConnStr as string)
Mybase.New()
_connStr=Connstr
end sub
public property ConnectionString as string
get
return _connStr
end get
set (Value as string)
_connStr=Value
end set
end property
public function GetCategories() as DataView
dim Ds as new Dataset()
dim Conn as new sqlconnection(_connStr)
dim Adap as new SqlDataAdapter("Select distinct CategoryName from Categories",Conn)
adap.fill(ds,"Categories")
return Ds.Tables("Categories").DefaultView
end function
public function GetProductsForCategory(Category as string) as dataview
Dim ds as new dataset()
dim conn as new Sqlconnection(_connStr)
dim Adap as new SqlDataAdapter("Select ProductName,Imagepath,Unitprice,c.CategoryId from Products p,categories c where c.Categoryname='" & category & "' and p.CategoryId=c.CategoryId",Conn)
adap.fill(ds,"Products")
return ds.tables("Products").DefaultView
end function
end class
end namespace
and Errors were:
DataObj.vb(2) :error BC30466: Namespace or type ‘Data’ for the Imports ‘System.Data’ can not be found.
DataObj.vb(3): error BC30466: Namespace or type ‘SqlClient’ for the Imports ‘System.Data.SqlClient’ can not be found.
DataObj.vb(32): error BC30002: Type ‘DataView’ is not defined.
DataObj.vb(34): error BC30002: Type ‘Dataset’ is not defined.
DataObj.vb(35): error BC30002: Type ‘SqlConnection’ is not defined
And so on for the sqldataadapter ,dataset,dataview errors were shown when I compiled the source file.
And for your information I am using
[u]1)WindowsXP Version 5.1
2)IIS Version 5.1
3)Microsoft .NET Framework Version 1.1
4)Microsoft .NET Framework SDK Version 1.1</u>
I also run the file sdkvars.bat to set the envoirnmental variables.Kindly solve me this problem that why the compiler is not compiling the file perfectly.I shall be grateful to you:).
I take it you are using the Command Line compiler to compile your program? If that is the case, you'll need to add a reference to the assemblies you are using in your command line statement. Importing System.Data.SqlClient, etc is not enough; you'll need to add references to the DLLs that contain these namespaces. Here's something that should work:
As you can see, by using /r (short for /reference) the required .DLLs are used in the compilation process.
If you are using Visual Studio .NET for compilation, make sure you add a reference to the required DLLs in your project. Expand the project, right-click References and then choose Add Reference to select these references.
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
I have just written a business component ending with the .vb extension. How do I compile it with Visual Studio.Net?
Also, I use the web.config file to hold the connection string for the DBase. When I compile the VB file from the command line I get errors that the compiler does not recognize "Configurationsettings"
(C:\AlertTypes.VB(14) : error BC30451: Name 'ConfigurationSettings' is not declared.
Dim myConnectString As String = ConfigurationSettings.AppSettings( "ConnectionString" )
You can out your VB class file inside a Class Library in Visual Studio (see the New Project dialog for this type of project). Then you can compile it in VS.NET like any other project.
Did you add the necessary references to the DLLs on the command line?
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Thanks Imar. I haven't used the Visual Studio.Net compiler yet but I solved the command line compilation by adding the proper DLL dependencies.
I have a problem with a new class I just wrote. The list of required parameters is long so much so that I seperated them into seperate lines using the following symbol: &_. The list is below.
strGender as String, strFirstName as String, strMiddleInitial as String, strLastName as String, &_
Are you talking about parameters for a function, or are you declaring variables?
In the first scenario, drop the & character, and just use the _. The & is used to concatenate two string values you may have split over two lines.
The _ is enough to indicate that the code continues on the next line:
Code:
Private Sub YourMethid(ByVal strGender As String, ByVal strFirstName As String, _
ByVal strMiddleInitial As String, ByVal strLastName As String, _
ByVal someOtherParam As String)
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Good reply Imar. I simply used the underscores and they worked. Also, I have problems using the following procedures in my source code: IsDate and Noithing. The compiler comes back with the error that the keywords have not been devlared. Is there a reference library I need to inlcude? Please let me know anyone.