I'm having problem parsing data between my Form1Main.cs and DataCode.cs.
In Form1Main.cs I have this:
private void Form1Main_Load(object sender, EventArgs e)
{
datacode.LoadData(dataGridView1, dt);
}
In DataCode.cs I have this:
public void LoadData(DataGridView dgv, DataTable dt)
{
dt = GetDataTable(@"C:\Users\" + user + @"\AppData\Local\KFredje & Co\Doga\Doga.csv");
dgv.DataSource = dt;
}
public static DataTable GetDataTable(string strFileName)
{
ADODB.Connection oConn = new ADODB.Connection();
oConn.Open("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";", "", "", 0);
string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName) + "]";
ADODB.Recordset rs = new ADODB.Recordset();
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();
DataTable dt = new DataTable();
rs.Open(strQuery, "Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";",
ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1);
adapter.Fill(dt, rs);
return dt;
}
Now the strange thing happens to me. So when I start my program, the dataGridView1 in Form1Main.cs get filled with the data from dt in DataCode.cs. Now, I want the dt as a DataTable being parsed from DataCode.cs to Form1Main.cs but this doesn't do a thing.
Any clue what I'm doing wrong?

New Topic/Question
Reply



MultiQuote




|