G
Guest
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=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\\Freddy\\Projects\\vb.net\\Project Track It\\bin\\Project.mdb";
Conn.ConnectionString = sConnString;
Conn.Open();
string select = "select * from Project";
OleDbDataAdapter da = new OleDbDataAdapter (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=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\\Freddy\\Projects\\vb.net\\Project Track It\\bin\\Project.mdb";
I want to do this:
OleDbConnection Conn = new OleDbConnection();
string sConnString = "Provider=Microsoft.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=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\\Freddy\\Projects\\vb.net\\Project Track It\\bin\\Project.mdb";
Conn.ConnectionString = sConnString;
Conn.Open();
string select = "select * from Project";
OleDbDataAdapter da = new OleDbDataAdapter (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=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\\Freddy\\Projects\\vb.net\\Project Track It\\bin\\Project.mdb";
I want to do this:
OleDbConnection Conn = new OleDbConnection();
string sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Project.mdb"; <-- it does not work like this