var source = await firebird.ExecuteDataTableAsync(sql);
var sb = new StringBuilder();
for (int i = 0; i < source.Rows.Count; i++)
{
var row = string.Join(",", source.Rows[i].ItemArray);
sb.AppendLine(row);
}
// the class
public class FB : IDatabaseProvider
{
private FbConnection Connection;
private FbTransaction Transaction;
public FB(string connectionString = null)
{
this.Connection = new FbConnection(connectionString);
}
public async Task<DataTable> ExecuteDataTableAsync(string sql, params IDbDataParameter[] parameters)
{
using (var cmd = new FbCommand(sql, this.Connection))
using (var adp = new FbDataAdapter(cmd))
{
cmd.Transaction = this.Transaction;
if (this.Connection.State != ConnectionState.Open)
{
await this.Connection.OpenAsync();
}
if (parameters.Length > 0)
{
cmd.Parameters.AddRange(parameters);
}
var data = new DataTable("data");
adp.Fill(data);
return data;
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter