D
Dan
I'm not able to access my variables that I've set in my
global.asax. Here is my simple code. Note: Error message
is below.
[[ global.asax ]]
<%@ Page Language="c#" %>
<script language="c#" runat="server">
string DbAccessString = "Provider=Microsoft.Jet.OleDb.4.0;
Data
Source=E:\\Users\\canadianmoneysaver\\public_html\\testing\
\survey.mdb";
</script>
[[ db_access_aspx ]]
<%@ Page Language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="c#" runat="server">
void Page_Load()
{
string strConnection =
DbAccessString;
data_src.Text =
strConnection;
OleDbConnection
objConnection = new OleDbConnection(strConnection);
try
{
objConnection.Open();
con_open.Text = "Connection opened success.<br />";
objConnection.Close();
con_close.Text = "Connection closed<br />";
}
catch (Exception e)
{
con_open.Text = "Connection failed to open.<br />";
con_close.Text=e.ToString();
}
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<h4>Testing data connection
<asp:Label id="data_src"
Text="" runat="server"/></h4>
<asp:Label id="con_open"
Text="" runat="server"/><br />
<asp:Label id="con_close"
Text="" runat="server"/><br />
PATH: <%= Server.MapPath("/testing")%> <br />
</body>
</html>
[[ ERROR MESSAGE ]]
Compiler Error Message: CS0103: The name 'DbAccessString'
does not exist in the class or
namespace 'ASP.db_access_aspx'
global.asax. Here is my simple code. Note: Error message
is below.
[[ global.asax ]]
<%@ Page Language="c#" %>
<script language="c#" runat="server">
string DbAccessString = "Provider=Microsoft.Jet.OleDb.4.0;
Data
Source=E:\\Users\\canadianmoneysaver\\public_html\\testing\
\survey.mdb";
</script>
[[ db_access_aspx ]]
<%@ Page Language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="c#" runat="server">
void Page_Load()
{
string strConnection =
DbAccessString;
data_src.Text =
strConnection;
OleDbConnection
objConnection = new OleDbConnection(strConnection);
try
{
objConnection.Open();
con_open.Text = "Connection opened success.<br />";
objConnection.Close();
con_close.Text = "Connection closed<br />";
}
catch (Exception e)
{
con_open.Text = "Connection failed to open.<br />";
con_close.Text=e.ToString();
}
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<h4>Testing data connection
<asp:Label id="data_src"
Text="" runat="server"/></h4>
<asp:Label id="con_open"
Text="" runat="server"/><br />
<asp:Label id="con_close"
Text="" runat="server"/><br />
PATH: <%= Server.MapPath("/testing")%> <br />
</body>
</html>
[[ ERROR MESSAGE ]]
Compiler Error Message: CS0103: The name 'DbAccessString'
does not exist in the class or
namespace 'ASP.db_access_aspx'