Posted 25 August 2023, 11:19 am EST
I have created a Windows Application and try to use C1.AdoNet.Csv to connect to my local file. The code as following:
[code]private void btnLoadData_Click(object sender, EventArgs e)
{
try
{
string csvConnectionString = @"Uri=C:\Users\DELL\Downloads\All_Movement_July2023.csv"; using (var con = new C1CSVConnection(csvConnectionString)) { con.Open(); // Create Read command var cmd = con.CreateCommand(); cmd.CommandText = "Select * From All_Movement_July2023.csv"; // Execute Read command and display fetched data DbDataReader rdr = cmd.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(rdr); if (dataTable != null) { fgData.BeginUpdate(); fgData.DataSource = dataTable; fgData.EndUpdate(); } } } catch (Exception ex) { MessageBox.Show("The error is\n" + ex.Message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}[/code]
But the error is shown that “Open connection failed. An item with the same key has already been added.”
C1 support pls.
Thanks,
Duyet Le