473,546 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid.Dataso urce

I have a class for DatabaseManager .cs that has all the connection path, add,
update, delete.I have a problem with the datagrid because I have a form that
contains the datagrid called frmAllProjects. cs, so how do I connected to my
dbmanager.cs from the form.
DatabaseManager Code:
OleDbConnection Conn = new OleDbConnection ();
string sConnString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=E:\\Fred dy\\Projects\\v b.net\\Project Track It\\bin\\Projec t.mdb";
Conn.Connection String = sConnString;
Conn.Open();

string select = "select * from Project";
OleDbDataAdapte r da = new OleDbDataAdapte r (select, Conn);
DataSet ds = new DataSet();
da.Fill(ds);
frmAllProjects code: <-- this is the form Code
DatabaseManager manager = new DatabaseManager ();
manager.path();
//Datagrid
dg1.Datasource = ds (); <-- I get the error here because ds is not found --
But when I have all the code on the datagrid it works fine.

Also I do not what th hardcode the data Source like this:
OleDbConnection Conn = new OleDbConnection ();
string sConnString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=E:\\Fred dy\\Projects\\v b.net\\Project Track It\\bin\\Projec t.mdb";

I want to do this:
OleDbConnection Conn = new OleDbConnection ();
string sConnString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=Project. mdb"; <-- it does not work like this
Nov 17 '05 #1
1 3885
Hi Freddy,

The simplest solution would probably be to have the DatabaseManager class
keep a reference to the retrieved dataset and return the reference as a
read-only public property.
Obviously the form containing the grid must keep a reference to the
DatabaseManager instance during the form's lifetime.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"freddy" <fr****@discuss ions.microsoft. com> wrote in message
news:6C******** *************** ***********@mic rosoft.com...
I have a class for DatabaseManager .cs that has all the connection path,
add,
update, delete.I have a problem with the datagrid because I have a form
that
contains the datagrid called frmAllProjects. cs, so how do I connected to
my
dbmanager.cs from the form.
DatabaseManager Code:
OleDbConnection Conn = new OleDbConnection ();
string sConnString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=E:\\Fred dy\\Projects\\v b.net\\Project Track It\\bin\\Projec t.mdb";
Conn.Connection String = sConnString;
Conn.Open();

string select = "select * from Project";
OleDbDataAdapte r da = new OleDbDataAdapte r (select, Conn);
DataSet ds = new DataSet();
da.Fill(ds);
frmAllProjects code: <-- this is the form Code
DatabaseManager manager = new DatabaseManager ();
manager.path();
//Datagrid
dg1.Datasource = ds (); <-- I get the error here because ds is not
found --
But when I have all the code on the datagrid it works fine.

Also I do not what th hardcode the data Source like this:
OleDbConnection Conn = new OleDbConnection ();
string sConnString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=E:\\Fred dy\\Projects\\v b.net\\Project Track It\\bin\\Projec t.mdb";

I want to do this:
OleDbConnection Conn = new OleDbConnection ();
string sConnString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=Project. mdb"; <-- it does not work like this


Nov 17 '05 #2

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

Similar topics

2
4323
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know how to use this code? please help! http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20862953.html
1
4291
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch the layout, some have child controls):
3
2771
by: CVerma | last post by:
Hi, I have an embedded datagrid within a datalist. I am not able to perfrom paging in the datagrid. Any ideas? Here is my code: Here is my Simplegrid.cs file: using System; using System.Collections; using System.ComponentModel; using System.Data;
4
3478
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a snippet from my .css file: *************************** body { margin:0; padding:0;
4
6184
by: dyw55a | last post by:
Donna Mar 15, 10:11 am show options Newsgroups: microsoft.public.dotnet.framework.adonet From: "Donna" <dyw...@yahoo.com> - Find messages by this author Date: 15 Mar 2005 10:11:56 -0800 Local: Tues, Mar 15 2005 10:11 am Subject: VB.NET dynamically create datagrid and set its datasource Reply | Reply to Author | Forward | Print |...
1
2353
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .. http://sf-f.org, weblog and search engine for fans and writers of
4
2266
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a combobox in a datagrid? Any other suggestions/articles on how to implement many-many relations in the frontend (which of course are 2 one-many...
17
2737
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1...
0
1301
by: Familjen Karlsson | last post by:
Hi I have downloaded some code and tried it and nothing happens with the datagrid. Explain what is wrong and what I have to do please. I have tried to Import the namespace Hamster and it didn't work. Explain what I have to do to make that work. Fia Imports System Imports System.Windows.Forms
8
3054
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly...
0
7504
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7694
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. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7792
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...
1
5360
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...
0
3491
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...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
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...

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.