473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Function name not declared?

Zak
I've been working on converting one of the major sites in my company to ASP.
net. I started with the migration assistant from Microsoft, which may or may
not have been a good idea. It worked OK on the last conversion though.

In trying to develop good coding practices, I'm using Option Strict. When I
made my last conversion, I wrote a relatively simple function where you
passed in an SQL string, and it returned an SqlDataReader. Worked great on
that site, but on this one I get the following error:

Compiler Error Message: BC30451: Name 'OpenRDR' is not declared.

Source Error:

Line 85: Dim sql as String = "SELECT * FROM All_Schools WHERE
TeamName='FRONT'"
Line 86: rdr = OpenRDR(sql)
Here is the dbsupport file as it currently is.

<script language="VB" runat="Server">
function OpenRDR(ByRef sql As String) As SqlDataReader
Dim Conn As SqlConnection = new SqlConnection(ConfigurationSettings.
AppSettings("ConnectionString"))
Dim dbComm As SqlCommand = new SqlCommand(sql,conn)
Dim rs As SqlDataReader

Conn.Open()
rs = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)
return rs
end function
</script>

Have I missed something in all my reading? I've only been at .NET for about
a week and a half, but I never saw anything like this in ASP. Any ideas are
welcome.
Nov 19 '05 #1
10 4432
Zak,

Have your referenced the support file?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Zak" <u15629@uwe> wrote in message news:572807c4a4f80@uwe...
I've been working on converting one of the major sites in my company to
ASP.
net. I started with the migration assistant from Microsoft, which may or
may
not have been a good idea. It worked OK on the last conversion though.

In trying to develop good coding practices, I'm using Option Strict. When
I
made my last conversion, I wrote a relatively simple function where you
passed in an SQL string, and it returned an SqlDataReader. Worked great
on
that site, but on this one I get the following error:

Compiler Error Message: BC30451: Name 'OpenRDR' is not declared.

Source Error:

Line 85: Dim sql as String = "SELECT * FROM All_Schools WHERE
TeamName='FRONT'"
Line 86: rdr = OpenRDR(sql)
Here is the dbsupport file as it currently is.

<script language="VB" runat="Server">
function OpenRDR(ByRef sql As String) As SqlDataReader
Dim Conn As SqlConnection = new SqlConnection(ConfigurationSettings.
AppSettings("ConnectionString"))
Dim dbComm As SqlCommand = new SqlCommand(sql,conn)
Dim rs As SqlDataReader

Conn.Open()
rs = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)
return rs
end function
</script>

Have I missed something in all my reading? I've only been at .NET for
about
a week and a half, but I never saw anything like this in ASP. Any ideas
are
welcome.

Nov 19 '05 #2
Zak
Yes sir, just a basic SSI.

<!--include file="ssi/dbsupport.aspx" -->

Where the function above is the only thing in dbsupport.aspx

S. Justin Gengo wrote:
Zak,

Have your referenced the support file?
I've been working on converting one of the major sites in my company to
ASP.

[quoted text clipped - 37 lines]
are
welcome.

Nov 19 '05 #3
I didn't know that you could use includes in aspx pages.

Move the function to a class and reference that class from the page.
The code will execute faster because it will be compiled.

"Zak" <u15629@uwe> wrote in message news:57283bad38138@uwe:
Yes sir, just a basic SSI.

<!--include file="ssi/dbsupport.aspx" -->

Where the function above is the only thing in dbsupport.aspx

S. Justin Gengo wrote:
Zak,

Have your referenced the support file?
I've been working on converting one of the major sites in my company to
ASP.

[quoted text clipped - 37 lines]
are
welcome.


Nov 19 '05 #4
Zak,

Are there other functions in that support file that you can call? Or do you
not have access to any of them from that page? If you don't have access to
any of them I'd check that you have the full path to the support file
written out properly. For example if there is a user control being dropped
onto a page it is easy to forget that the control may need a different path
to a file than the page itself uses...

That's my best guess so far.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Zak" <u15629@uwe> wrote in message news:57283bad38138@uwe...
Yes sir, just a basic SSI.

<!--include file="ssi/dbsupport.aspx" -->

Where the function above is the only thing in dbsupport.aspx

S. Justin Gengo wrote:
Zak,

Have your referenced the support file?
I've been working on converting one of the major sites in my company to
ASP.

[quoted text clipped - 37 lines]
are
welcome.

Nov 19 '05 #5
Zak
There were no other functions in dbsupport, but I added another, extremely
simple one in order to test, and could not access it. Next, I tried losing
the SSI and converting it into a user control. Well, it appears to have been
properly converted (there are no errors relating to it), but I continue to
have the same problem accessing my function. The included file is simply one
directory down from the index.aspx file, in ssi/dbsupport.ascx (now, was aspx)
.. Still no joy. Thanks so far.

I don't know enough about VB to be comfortable trying to make this a class.
Is there any other options?

S. Justin Gengo wrote:
Zak,

Are there other functions in that support file that you can call? Or do you
not have access to any of them from that page? If you don't have access to
any of them I'd check that you have the full path to the support file
written out properly. For example if there is a user control being dropped
onto a page it is easy to forget that the control may need a different path
to a file than the page itself uses...

That's my best guess so far.
Yes sir, just a basic SSI.

[quoted text clipped - 11 lines]
are
welcome.

Nov 19 '05 #6
You should not be using include files in ASP.NET.

This looks like something that should be in a class library, or something
that can be called via inheritance.

"Zak" <u15629@uwe> wrote in message news:572807c4a4f80@uwe...
I've been working on converting one of the major sites in my company to
ASP.
net. I started with the migration assistant from Microsoft, which may or
may
not have been a good idea. It worked OK on the last conversion though.

In trying to develop good coding practices, I'm using Option Strict. When
I
made my last conversion, I wrote a relatively simple function where you
passed in an SQL string, and it returned an SqlDataReader. Worked great
on
that site, but on this one I get the following error:

Compiler Error Message: BC30451: Name 'OpenRDR' is not declared.

Source Error:

Line 85: Dim sql as String = "SELECT * FROM All_Schools WHERE
TeamName='FRONT'"
Line 86: rdr = OpenRDR(sql)
Here is the dbsupport file as it currently is.

<script language="VB" runat="Server">
function OpenRDR(ByRef sql As String) As SqlDataReader
Dim Conn As SqlConnection = new SqlConnection(ConfigurationSettings.
AppSettings("ConnectionString"))
Dim dbComm As SqlCommand = new SqlCommand(sql,conn)
Dim rs As SqlDataReader

Conn.Open()
rs = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)
return rs
end function
</script>

Have I missed something in all my reading? I've only been at .NET for
about
a week and a half, but I never saw anything like this in ASP. Any ideas
are
welcome.

Nov 19 '05 #7
re:
I didn't know that you could use includes in aspx pages.
You *can* use includes, but any code in them won't execute.
They're OK for HTML, but I prefer to use web user controls for that.

re: Move the function to a class and reference that class from the page.
Good advice...

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Josh Kerr" <jo******@gmail.com.invalid> wrote in message
news:IC*****************@tornado.texas.rr.com...I didn't know that you could use includes in aspx pages. Move the function to a class and reference that class from the page. The code will
execute faster because it will be compiled. "Zak" <u15629@uwe> wrote in message news:57283bad38138@uwe:
Yes sir, just a basic SSI.

<!--include file="ssi/dbsupport.aspx" -->

Where the function above is the only thing in dbsupport.aspx

S. Justin Gengo wrote:
>Zak,
>
>Have your referenced the support file?
>
>> I've been working on converting one of the major sites in my company to
>> ASP.
>[quoted text clipped - 37 lines]
>> are
>> welcome.

Nov 19 '05 #8
Zak
OK, I'm trying (big emphasis on trying) to make a class. Here is my vb code:

Imports System.Data
Imports System.Data.SqlClient

Namespace DBSupport
Public Class dataRdr
Public Function OpenRDR(ByRef sql As String) As SqlDataReader
Dim Conn As SqlConnection = New SqlConnection
("Server=ServerStuff;Database=ffn;User
ID=pub;Password=sa;Trusted_Connection=False")
Dim dbComm As SqlCommand = New SqlCommand(sql, Conn)
Dim rs As SqlDataReader

Conn.Open()
rs = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)
Return rs
End Function
End Class
End Namespace

Compliled that, put it in the /bin directory, then Imported the namespace on
my page:
<%@ Import Namespace="DBSupport" %>

Here's where it might be shaky:
Dim testthing As new DBSupport.dataRdr
Dim sql as String = "SELECT * FROM All_Schools WHERE TeamName='FRONT'"
rs = testthing.OpenRDR(sql)
Marina wrote:
You should not be using include files in ASP.NET.

This looks like something that should be in a class library, or something
that can be called via inheritance.
I've been working on converting one of the major sites in my company to
ASP.

[quoted text clipped - 37 lines]
are
welcome.

Nov 19 '05 #9
Zak
Oh, and my current error is:

Compiler Error Message: BC30002: Type 'DBSupport.dataRdr' is not defined.

Source Error:

Line 82: <div style='position:absolute;top:420;left:192;height:1 0;width:
480;height:257;text-align:left' class='whitebg'>
Line 83: <%
Line 84: Dim testthing As new DBSupport.dataRdr
Line 85: Dim sql as String = "SELECT * FROM All_Schools WHERE
TeamName='FRONT'"
Zak wrote:
OK, I'm trying (big emphasis on trying) to make a class. Here is my vb code:

Imports System.Data
Imports System.Data.SqlClient

Namespace DBSupport
Public Class dataRdr
Public Function OpenRDR(ByRef sql As String) As SqlDataReader
Dim Conn As SqlConnection = New SqlConnection
("Server=ServerStuff;Database=ffn;User
ID=pub;Password=sa;Trusted_Connection=False")
Dim dbComm As SqlCommand = New SqlCommand(sql, Conn)
Dim rs As SqlDataReader

Conn.Open()
rs = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)
Return rs
End Function
End Class
End Namespace

Compliled that, put it in the /bin directory, then Imported the namespace on
my page:
<%@ Import Namespace="DBSupport" %>

Here's where it might be shaky:
Dim testthing As new DBSupport.dataRdr
Dim sql as String = "SELECT * FROM All_Schools WHERE TeamName='FRONT'"
rs = testthing.OpenRDR(sql)
You should not be using include files in ASP.NET.

[quoted text clipped - 6 lines]
are
welcome.

Nov 19 '05 #10
Did you recompile your project?
Is there a reason you are putting the code as a script instead of using the
code-behind model? This makes coding much easier and provides intellisense.

And one more note, it is standard practice that all class names begin with a
capital letter.
I'm also not quite sure why you are passing the string ByRef. Normally you
would only do that if the function were to modify the string and could not
return it as a result - though usually you can modify a function to return
an object that has a bunch of properties for all the return values. In this
case though, you are not modifying the string, and it is far more clear to
have it ByVal (which is the default) so the caller isn't wondering why it's
ByRef and if they should expect their string to be modified in some way.

And lastly, you might want a Try/Catch block in your function, so that if
any errors occur executing the query, you can close the connection.

"Zak" <u15629@uwe> wrote in message news:57295328fb774@uwe...
Oh, and my current error is:

Compiler Error Message: BC30002: Type 'DBSupport.dataRdr' is not defined.

Source Error:

Line 82: <div style='position:absolute;top:420;left:192;height:1 0;width:
480;height:257;text-align:left' class='whitebg'>
Line 83: <%
Line 84: Dim testthing As new DBSupport.dataRdr
Line 85: Dim sql as String = "SELECT * FROM All_Schools WHERE
TeamName='FRONT'"
Zak wrote:
OK, I'm trying (big emphasis on trying) to make a class. Here is my vb
code:

Imports System.Data
Imports System.Data.SqlClient

Namespace DBSupport
Public Class dataRdr
Public Function OpenRDR(ByRef sql As String) As SqlDataReader
Dim Conn As SqlConnection = New SqlConnection
("Server=ServerStuff;Database=ffn;User
ID=pub;Password=sa;Trusted_Connection=False")
Dim dbComm As SqlCommand = New SqlCommand(sql, Conn)
Dim rs As SqlDataReader

Conn.Open()
rs = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)
Return rs
End Function
End Class
End Namespace

Compliled that, put it in the /bin directory, then Imported the namespace
on
my page:
<%@ Import Namespace="DBSupport" %>

Here's where it might be shaky:
Dim testthing As new DBSupport.dataRdr
Dim sql as String = "SELECT * FROM All_Schools WHERE TeamName='FRONT'"
rs = testthing.OpenRDR(sql)
You should not be using include files in ASP.NET.

[quoted text clipped - 6 lines]
are
welcome.

Nov 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: kazack | last post by:
I am a little confused with code I am looking at. My c++ book does not go into passing a structure to a function so I pulled out a c book which does. and I do not understand the prototype verses...
10
by: sjbrown8 | last post by:
I have the piece of code below, and when i try compiling with the line g++ 753075304.cpp I get the following error message: 753075304.cpp: In function 'int main()': 753075304.cpp:29: error:...
2
by: nospam_timur | last post by:
I'm writing a Linux device driver that needs to compile with several different Linux versions. In my code, I need to reference certain functions by their address alone. Something like this: ...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
0
by: Frank | last post by:
Short Version of Question: Can anyone provide an example of how I should embed the ActiveX and license, and then use it in a function?
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
4
by: Ray | last post by:
Hello, I think I've had JavaScript variable scope figured out, can you please see if I've got it correctly? * Variables can be local or global * When a variable is declared outside any...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
28
by: Bill | last post by:
Hello All, I am trying to pass a struct to a function. How would that best be accomplished? Thanks, Bill
1
by: James Kanze | last post by:
On Apr 11, 3:20 am, Ian Collins <ian-n...@hotmail.comwrote: Yes. ADL kicks in, and finds the function declared in scope wurst::foo.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.