i have 2,000,000 record in my table and excel don't accept more than 1,040,000 record what should i do ?????????
i use this code
<pre>public void DumpTableToFile(SqlConnection connection, string tableName, string destinationFile)
{
using (var command = new SqlCommand("select * from tabl", connection))
{
using (var reader = command.ExecuteReader())
{
using (StreamWriter sw = new StreamWriter(File.Open(destinationFile, FileMode.Create), Encoding.UTF8))
{
string[] columnNames = GetColumnNames(reader).ToArray();
int numFields = columnNames.Length;
sw.WriteLine(string.Join(",", columnNames));
if (reader.HasRows)
{
while (reader.Read())
{
string[] columnValues = Enumerable.Range(0, numFields)
.Select(i => reader.GetValue(i).ToString())
.Select(field => string.Concat("\"", field.Replace("\"", "\"\""), "\""))
.ToArray();
sw.WriteLine(string.Join(",", columnValues));
}
}
}
}
}
}
private IEnumerable<string> GetColumnNames(IDataReader reader)
{
foreach (DataRow row in reader.GetSchemaTable().Rows)
{
yield return (string)row["ColumnName"];
}
}
private void Button5_Click(object sender, EventArgs e)
{
SqlConnection _connection = new SqlConnection();
SqlDataAdapter _dataAdapter = new SqlDataAdapter();
SqlCommand _command = new SqlCommand();
DataTable _dataTable = new DataTable();
_connection = new SqlConnection();
_dataAdapter = new SqlDataAdapter();
_command = new SqlCommand();
_dataTable = new DataTable();
_connection.ConnectionString = "connaction";
_connection.Open();
SaveFileDialog saveFileDialogCSV = new SaveFileDialog();
saveFileDialogCSV.InitialDirectory = Application.ExecutablePath.ToString();
saveFileDialogCSV.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
saveFileDialogCSV.FilterIndex = 1;
saveFileDialogCSV.RestoreDirectory = true;
string path_csv = "";
if (saveFileDialogCSV.ShowDialog() == DialogResult.OK)
{
path_csv = saveFileDialogCSV.FileName.ToString();
}
DumpTableToFile(_connection, "tbl_trmc", path_csv);
}
}
What I have tried:
i search about it bout didn't find any thing to help me