473,699 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Outside function OleDbConnection Conn = new OleDbConnection

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="Syst em.Data" %>
<%@ import Namespace="Syst em.Data.OleDb" %>
<script runat="server">
OleDbConnection Conn = new OleDbConnection
("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source="+
Server.MapPath( "/tyaspnet21days" ) +"\\banking1.md b");

void Page_Load(Objec t Sender, EventArgs e) {
if (!Page.IsPostBa ck) {
FillDataGrid();
}
}

CS0118: 'System.Web.UI. Page.Server' denotes a 'property' where a
'class' was expected

I get a compilation error on line 5 "OleDbConnectio n 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=Micr osoft.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(Objec t 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_as px'

Thank you.
Nov 15 '05 #1
1 7232
I% SAY :::
does it work if you put it all on the same line

OleDbConnection Conn = new
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source="+ Server.MapPath( "/tyaspnet21days" ) +"\\banking1.md b");

does it work if you do

OleDbConnection Conn = new OleDbConnection ();

and set the properties later, individually ?

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="Syst em.Data" %>
<%@ import Namespace="Syst em.Data.OleDb" %>
<script runat="server">
OleDbConnection Conn = new OleDbConnection
("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source="+
Server.MapPath( "/tyaspnet21days" ) +"\\banking1.md b");

void Page_Load(Objec t Sender, EventArgs e) {
if (!Page.IsPostBa ck) {
FillDataGrid();
}
}

CS0118: 'System.Web.UI. Page.Server' denotes a 'property' where a
'class' was expected

I get a compilation error on line 5 "OleDbConnectio n 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=Micr osoft.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(Objec t 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_as px'

Thank you.


Nov 15 '05 #2

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

Similar topics

0
1235
by: ecowalker | last post by:
Hello, I've try the following code in the ASPX and it throw a Security Exception in the runtime, but I've try to run on my colleagues machine without any problem. I am using XP Pro and IIS5.1 , I've recently change the file system from FAT32 to NTFS, is is the matter of NTFS security issue or something else?
0
1655
by: Ray | last post by:
Hi All I've tried to read a .csv file and bind the data to a datagrid. I am doing sth like this: conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"+ "Data Source=" + csvPath + ";" + "Extended Properties=\"text;HDR=YES;FMT=Delimited\""); conn.Open(); //Read all data into a data table
1
1231
by: Souloron | last post by:
Here what I did: string cmdText = String.Format(("CREATE TABLE {0} (dno int primary key, Sunday char(5), Monday char(5), Tuesday char(5), Wednesday char(5), Thursday char(5), Friday char(5))"), tableName); OleDbConnection conn = new OleDbConnection(Form1.ConnectionString); conn.Open(); OleDbCommand cmd = new OleDbCommand(cmdText, conn); ...
1
3043
by: Sabine25 | last post by:
Hello, It's the first time that I program in C# with Visual Studio and I've got a problem, I would like to know where is my error! This is my code: OleDbConnection conn = null; private void button1_Click(object sender, EventArgs e) {
4
8659
by: tamarindm | last post by:
I am using the following to connect to a Sybase server. OleDbConnection Conn= new OleDbConnection(); string connstr = "Provider=Sybase ASE OLE DB Provider;Data Source=SERVER;User ID=USER;Password=password;database=DB"; Conn.Open(); I get the following error. What could be the problem ?
9
2822
by: Justin Voelker | last post by:
I have a configuration file that contains the host, username, password, and database name required for any database connections. The config file runs through a few if/then/else statements to determine if the website is local or remote and if it is local if it is the test site or "live" site then it sets the 4 variables. I am trying to implement a webstats package that has it's own config file. I would the new config file to be able to use...
2
3251
by: user | last post by:
Hi everyone, Im using the following conn string in asp.net 1.1 using vb.net: Dim conn As New OleDbConnection("Provider=MS Remote;Remote Server=http://myintranetserver/; Remote Provider=Microsoft.Jet.OLEDB. 4.0;Data Source=c:\pass\be\quiz.mdb;uid=;Password=;") Whenever I execute rs.executereader,
2
1339
by: dotnetnovice | last post by:
Hi everybody! I have a problem and need help Here is the code. public void GetAllValues(Person V) { SqlConnection conn = new SqlConnection(ConnectionString); SqlCommand objSql = new SqlCommand();
3
1780
by: DaveRook | last post by:
Hello Let me show you the code I'm trying to do and then I'll ask the question: SqlDataReader rdr = null; SqlConnection conn = new SqlConnection(strConn); string strSQL = "SELECT * FROM View_ProductRange WHERE "+sqlSearch+""; SqlCommand cmd = new SqlCommand(strSQL, conn);
0
8617
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8884
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7751
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.