L
Lilly
Hi all.
I'm really sorry for this post, I'm sure most of you will think it's a
silly question, but the following doesn't work and I'm really new to
ASP.NET:
<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
OleDbConnection Conn = new OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+
Server.MapPath("/tyaspnet21days") +"\\banking1.mdb");
void Page_Load(Object Sender, EventArgs e) {
if (!Page.IsPostBack) {
FillDataGrid();
}
}
CS0118: 'System.Web.UI.Page.Server' denotes a 'property' where a
'class' was expected
I get a compilation error on line 5 "OleDbConnection Conn = new
OleDbConnection"
It doesn't work and I know it will not work that way, but what is the
reason?
In VB.net I can use:
dim Conn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source="& Server.MapPath("/tyaspnet21days") &"\banking1.mdb")
I got the code from Teach Yourself ASP.NET in 21 days, I would also
like to add that none of the examples work.
If I place the connection in "void Page_Load(Object Sender, EventArgs
e) {" it works, but then I get errors from functions trying to use
that connection....
CS0103: The name 'Conn' does not exist in the class or namespace
'ASP.Project_aspx'
Thank you.
I'm really sorry for this post, I'm sure most of you will think it's a
silly question, but the following doesn't work and I'm really new to
ASP.NET:
<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
OleDbConnection Conn = new OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+
Server.MapPath("/tyaspnet21days") +"\\banking1.mdb");
void Page_Load(Object Sender, EventArgs e) {
if (!Page.IsPostBack) {
FillDataGrid();
}
}
CS0118: 'System.Web.UI.Page.Server' denotes a 'property' where a
'class' was expected
I get a compilation error on line 5 "OleDbConnection Conn = new
OleDbConnection"
It doesn't work and I know it will not work that way, but what is the
reason?
In VB.net I can use:
dim Conn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source="& Server.MapPath("/tyaspnet21days") &"\banking1.mdb")
I got the code from Teach Yourself ASP.NET in 21 days, I would also
like to add that none of the examples work.
If I place the connection in "void Page_Load(Object Sender, EventArgs
e) {" it works, but then I get errors from functions trying to use
that connection....
CS0103: The name 'Conn' does not exist in the class or namespace
'ASP.Project_aspx'
Thank you.