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
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
Comment