Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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
Welcome to the p2p.wrox.com Forums.

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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 6th, 2003, 04:01 PM
Registered User
 
Join Date: Aug 2003
Location: Karachi, Sindh, Pakistan.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default "Errors in Compiling Source File"





     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
__________________
Noman
Reply With Quote
  #2 (permalink)  
Old September 7th, 2003, 05:10 AM
Imar's Avatar
Wrox Author
Points: 66,536, Level: 100
Points: 66,536, Level: 100 Points: 66,536, Level: 100 Points: 66,536, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,117
Thanks: 65
Thanked 1,380 Times in 1,360 Posts
Default

Hi Noman,

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:

vbc /target:library /r:System.Data.dll /r:System.dll /r:System.xml.dll YourVBFile.vb

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.
Reply With Quote
  #3 (permalink)  
Old March 2nd, 2004, 06:08 PM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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" )

How do I fix this?
Reply With Quote
  #4 (permalink)  
Old March 3rd, 2004, 03:03 AM
Imar's Avatar
Wrox Author
Points: 66,536, Level: 100
Points: 66,536, Level: 100 Points: 66,536, Level: 100 Points: 66,536, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,117
Thanks: 65
Thanked 1,380 Times in 1,360 Posts
Default

Hi there,

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.
Reply With Quote
  #5 (permalink)  
Old March 15th, 2004, 07:57 PM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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, &_

But that does not work. How can I resolve this?

Reply With Quote
  #6 (permalink)  
Old March 16th, 2004, 03:39 AM
Imar's Avatar
Wrox Author
Points: 66,536, Level: 100
Points: 66,536, Level: 100 Points: 66,536, Level: 100 Points: 66,536, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,117
Thanks: 65
Thanked 1,380 Times in 1,360 Posts
Default

Hi there,

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.
Reply With Quote
  #7 (permalink)  
Old March 16th, 2004, 09:47 AM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #8 (permalink)  
Old March 16th, 2004, 10:10 AM
Imar's Avatar
Wrox Author
Points: 66,536, Level: 100
Points: 66,536, Level: 100 Points: 66,536, Level: 100 Points: 66,536, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,117
Thanks: 65
Thanked 1,380 Times in 1,360 Posts
Default

Is Noithing a spelling mistake in your post here, or in your code? If the latter is true, change it to Nothing.

I think that IsDate is located somewhere in the VisualBasic namespace, probably here: Microsoft.VisualBasic.Information.IsDate

I think you'll need to reference the VisualBasic.dll from the command line too.



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #9 (permalink)  
Old March 16th, 2004, 10:33 AM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The "Noithing" was a typo. I had menat to say "Nothing". I included the Visual Basic library and it comiles well now.

Thanks Imar

Reply With Quote
  #10 (permalink)  
Old March 18th, 2004, 03:58 PM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Imar. Does this ring a bell? I tried to compile a VB business componet and got the following error:

C:\Utilities.vb(55) : error BC30451: Name 'MapPath' is not declared.

        If File.Exists( MapPath( strFileName ) ) Then

Let me know what you think.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors Compiling Jiffyman C++ Programming 5 October 16th, 2008 01:27 AM
Need Help ASAP w/Compiling Open Source Game alpine C++ Programming 2 April 11th, 2007 04:04 PM
Errors when Compiling a Class File Jim3 General .NET 1 March 16th, 2005 12:57 AM
errors compiling on beta2 gaid BOOK: ASP.NET Website Programming Problem-Design-Solution 3 February 20th, 2005 11:25 PM
Error in source code compiling angelika J2EE 2 December 29th, 2003 10:45 AM



All times are GMT -4. The time now is 03:48 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.