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:).
Noman