Please i want to COnvert DataTable thta has Blob as part of its fields to CSV.
so i can do MySqlBulkCopy to MySql Database.
I have sucessfully copy all columns except the image data.
I need help please.
What I have tried:
I have successfully bulkcopy all columns except the blob coumn it copies it and inserts "System.Byte" in the database
This is the code to insert to Database
IGRDal dl = SQLDalFactory.GetDal(GrConnector.AccessSQLDal);
string tempCsvFileSpec = APP_PATH+ @"\dump.csv";
using (StreamWriter writer = new StreamWriter(tempCsvFileSpec))
DBHelper.WriteDataTable(dl.CreateDataTable(), writer, false);
var msbl = new MySqlBulkLoader(dbConection);
msbl.TableName = "tb_templates";
msbl.FileName = tempCsvFileSpec;
msbl.FieldTerminator = ",";
msbl.FieldQuotationCharacter = '"';
this is the code to make CSV
public static void WriteDataTable(DataTable sourceTable, TextWriter writer, bool includeHeaders)
IEnumerable<string> headerValues = sourceTable.Columns
.Select(column => QuoteValue(column.ColumnName));
IEnumerable<string> items = null;
foreach (DataRow row in sourceTable.Rows)
items = row.ItemArray.Select(o => QuoteValue(o.ToString()));
private static string QuoteValue(string value)
value.Replace("\"", "\"\""), "\"");