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 .
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
public class DataObj
private _connStr as string
public sub New()
public sub New(ConnStr as string)
public property ConnectionString as string
set (Value as string)
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)
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)
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.
Everyone is unique, except for me.
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:
Private Sub YourMethid(ByVal strGender As String, ByVal strFirstName As String, _
ByVal strMiddleInitial As String, ByVal strLastName As String, _
ByVal someOtherParam As String)
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.