Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2005, 01:30 AM
Authorized User
 
Join Date: Dec 2004
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default Problem with user control (ad rotator)

I'm not sure, but i believe that i have this right? here's the .ascx:
Code:
     <%@ IMPORT NAMESPACE="SYSTEM.DATA"%>
     <%@ IMPORT NAMESPACE="SYSTEM.DATA.OLEDB"%>

     <SCRIPT RUNAT=SERVER language=vb>

     DIM CN2 AS OLEDBConnection = new OLEDBConnection("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=Z:\WWW\ADS\ADS.mdb") 
     DIM DA2 AS OleDbDataAdapter  = NEW OLEDBDATAADAPTER("SELECT * FROM ADS",CN2)
     DIM DS2 AS DataSet = NEW DataSet()
     DA2.Fill (DS2, ("ADS")) 
     DIM RC2 AS Integer = DS2.Tables ("ADS").ROWS.COUNT

     DIM RANC17 = INT(RND * RC2)
 IADS.ImageUrl = "HTTP://WWW.ADS.GRIMMUSIC.COM/" & (DS2.Tables ("ADS").ROWS(RANC17).ITEM(0).TOSTRING()) &"/" & (DS2.Tables ("ADS").ROWS(RANC17).ITEM(2).TOSTRING())
     ADS.NavigateUrl =  (DS2.Tables ("ADS").ROWS(RANC17).ITEM(1).TOSTRING()) 

     </SCRIPT>


     <TABLE  WIDTH=99%  >
     <tr><td align="Center" width="100%" height="80" colspan="8">
     <CENTER>
         <asp:HyperLink Runat="Server" Target="MAIN" ID="ADS" >
         <asp:Image ID="IADS"  Runat="Server" />
     </asp:HyperLink> 
     </TD></TR>
     </TABLE>



But here is the error i'm getting:
Code:
     Compiler Error Message: BC30188: Declaration  expected.

     Source Error:


       Line 6:  DIM DA2 AS OleDbDataAdapter  = NEW OLEDBDATAADAPTER("SELECT * FROM ADS",CN2)
    Line 7:  DIM DS2 AS DataSet = NEW DataSet()
    Line 8:  DA2.Fill (DS2, ("ADS")) 
    Line 9:  DIM RC2 AS Integer = DS2.Tables ("ADS").ROWS.COUNT
    Line 10:   
     Source File:  Z:\www\PROFILES\ADS.ASCX    Line: 8 


      Show Detailed Compiler Output:

    Z:\www\PROFILES\ADS.ASCX(8) : error BC30188: Declaration expected.

    DA2.Fill (DS2, ("ADS")) 
    ~~~                     
    Z:\www\PROFILES\ADS.ASCX(12) : error BC30188: Declaration expected.

 IADS.ImageUrl = "HTTP://WWW.ADS.GRIMMUSIC.COM/" & (DS2.Tables ("ADS").ROWS(RANC17).ITEM(0).TOSTRING()) &"/" & (DS2.Tables ("ADS").ROWS(RANC17).ITEM(2).TOSTRING())
    ~~~~ 
    Z:\www\PROFILES\ADS.ASCX(13) : error BC30188: Declaration expected.

    ADS.NavigateUrl =  (DS2.Tables ("ADS").ROWS(RANC17).ITEM(1).TOSTRING()) 
    ~~~

 and here is how i registered the tag:
<%@ REGISTER TAGPREFIX="AN" TAGNAME="AD" SRC="ADS.ASCX" %>

and here is how i'm using it in the page:
<AN:AD RUNAT=SERVER ID=ADS />

and the tag itself IS within the form tag? so i'm stumped. but i have another usercontrol in the same aspx page. will that cause a conflict? i don't think it can, and besides, i made sure NONE of the tag prperties were named the same, (like: tageprefix, tagname, etc).
thanks in advance to anyone who replies.

[email protected]
WWW.GRIMMUSIC.COM
__________________
---------------------------
A Black sheep moves easy in the darkness.
[email protected]
WWW.GRIMMUSIC.COM
 
Old May 3rd, 2005, 06:16 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default


I think you should write the code in the OnLoad Event of the User Control. Inside a class you cannot have statements outside the methods.

Code:
Sub UserControl_Load(sender As Object, e As EventArgs)
    DIM CN2 AS OLEDBConnection = new OLEDBConnection("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=Z:\WWW\ADS\ADS.mdb")
    DIM DA2 AS OleDbDataAdapter  = NEW OLEDBDATAADAPTER("SELECT * FROM ADS",CN2)
    DIM DS2 AS DataSet = NEW DataSet()
    DA2.Fill (DS2, ("ADS"))
    DIM RC2 AS Integer = DS2.Tables ("ADS").ROWS.COUNT

    DIM RANC17 = INT(RND * RC2)
    IADS.ImageUrl = "HTTP://WWW.ADS.GRIMMUSIC.COM/" & (DS2.Tables ("ADS").ROWS(RANC17).ITEM(0).TOSTRING()) &"/" & (DS2.Tables ("ADS").ROWS(RANC17).ITEM(2).TOSTRING())
    ADS.NavigateUrl =  (DS2.Tables ("ADS").ROWS(RANC17).ITEM(1).TOSTRING())
End Sub
Regards
Ganesh
 
Old May 4th, 2005, 06:49 PM
Authorized User
 
Join Date: Dec 2004
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default

THANK YOU VERY MUch, i should've known that, but i am very new to programming.
either way, you helped me fix it, and i apreciate it.

---------------------------
A Black sheep moves easy in the darkness.
[email protected]
WWW.GRIMMUSIC.COM
 
Old May 5th, 2005, 12:30 AM
Authorized User
 
Join Date: Dec 2004
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default

Ok, one more question:
evidently the script is fine, because i'm not getting any errors from it,
but the server controls that are requiring the info returned from the script isn't getting it's info,
here's what it looks like again:
************************************************** ************************
<%@ IMPORT NAMESPACE="SYSTEM.DATA"%>
<%@ IMPORT NAMESPACE="SYSTEM.DATA.OLEDB"%>

<SCRIPT RUNAT=SERVER>

SUB CONTROL_LOAD(SENDER AS OBJECT, E AS EVENTARGS)

DIM CN2 AS OLEDBConnection = new OLEDBConnection("PROVIDER=MICROSOFT.JET.OLEDB.4.0; Data Source=Z:\WWW\ADS\ADS.mdb")
DIM DA2 AS OleDbDataAdapter = NEW OLEDBDATAADAPTER("SELECT * FROM ADS",CN2)
DIM DS2 AS DataSet = NEW DataSet()
DA2.Fill (DS2, ("ADS"))
DIM RC2 AS Integer = DS2.Tables ("ADS").ROWS.COUNT

DIM RANC17 = INT(RND * RC2)
IADS.ImageUrl = "HTTP://WWW.GRIMMUSIC.COM/3.GIF" 'DS2.Tables ("ADS").ROWS(RANC17).ITEM(0).TOSTRING()
ADS.NavigateUrl = DS2.Tables ("ADS").ROWS(RANC17).ITEM(1).TOSTRING()
END SUB

</SCRIPT>


<TABLE WIDTH=99% >
<tr><td align="Center" width="100%" height="80" colspan="8">
<CENTER> THIS IS A TEST, IF I SEE THIS, THAT MEANS IT WORKS
    <asp:HyperLink Runat="Server" Target="MAIN" ID="ADS" >
    <asp:Image ID="IADS" Runat="Server" />
</asp:HyperLink>
</TD></TR>
</TABLE>
************************************************** ********************************
but i'm not getting any errors at all??? and the user control is between the "<form runat=server>" and "</form>" tags??? any ideas? tahnks.

---------------------------
A Black sheep moves easy in the darkness.
[email protected]
WWW.GRIMMUSIC.COM
 
Old May 5th, 2005, 12:52 AM
Authorized User
 
Join Date: Dec 2004
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ALEX_GRIM
Default

NEVEr mind, i fixed it. i thought you couldn't call the page's load method in
your .ascx method as well as the page that is going to be loading it,
just like you can't have a "<form runat=server>" tag in the .ascx,
but it looks like i was wrong, so it's fixed. but i'm willing to
bet i could've simply called the method for the control's load
method from the page's script that will be loading it as well, like:
"control.load"

---------------------------
A Black sheep moves easy in the darkness.
[email protected]
WWW.GRIMMUSIC.COM





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add existing AD user to AD group via ADSI? thiazi Classic ASP Basics 0 August 24th, 2007 09:27 PM
Ad Rotator js_newbie Javascript 0 April 4th, 2007 11:30 PM
ad rotator help crazzzy90210 Classic ASP Components 2 November 25th, 2005 12:11 AM
Chapter 11.....Ad Rotator problems ou812 BOOK: Beginning ASP 3.0 0 October 30th, 2003 11:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.