Hello
In C#.NET VS2019, I Write a query using oled.
Here, The problem of uploading to memory at once.
Problem code ( The problem of uploading to memory at once. )
In C#.NET VS2019, I Write a query using oled.
Here, The problem of uploading to memory at once.
Problem code ( The problem of uploading to memory at once. )
C#:
string connectionString = "";
OleDbCommand cmd = null;
OleDbConnection objCon = null;
OleDbDataAdapter objDA = null;
private string collect_Con(string szFileExtension, string szPath)
{
connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=
" + szPath + ";Extended Properties=\"Excel 12.0;HDR=YES;\"";
return connectionString;
}
private void cmdReadExcel_Click(object sender, EventArgs e)
{
DataSet objDS = new DataSet();
string szConStr = collect_Con(System.IO.Path.GetExtension(txtFilePath.Text), txtFilePath.Text);
try
{
objCon = new OleDbConnection(szConStr);
objCon.Open();
objDA = new System.Data.OleDb.OleDbDataAdapter("select *from [Sheet1$]", objCon);
DataTable objDTExcel = new DataTable();
objDA.Fill(objDTExcel);
dataGridView1.DataSource = objDTExcel;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message); }
finally
{
if (objDA != null)
{
objDA.Dispose();
objDA = null;
}
if (objCon != null)
{
objCon.Close();
objCon.Dispose();
objCon = null;
}
}
}
Last edited by a moderator: