本文整理汇总了C#中System.Data.DataSet类的典型用法代码示例。如果您正苦于以下问题:C# System.Data.DataSet类的具体用法?C# System.Data.DataSet怎么用?C# System.Data.DataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Data.DataSet类属于命名空间,在下文中一共展示了System.Data.DataSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestStreamDataSet
private static void TestStreamDataSet()
{
//Create a sample DataSet
System.Data.DataSet ds = new System.Data.DataSet();
System.Data.DataTable table = ds.Tables.Add("Table1");
table.Columns.Add("Col1", typeof(string));
table.Columns.Add("Col2", typeof(double));
table.Rows.Add("Value 1", 59.7);
table.Rows.Add("Value 2", 59.9);
byte[] buffer;
//Serialize the DataSet (where ds is the dataset)
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
DevAge.Data.StreamDataSet.Write(stream, ds,
DevAge.Data.StreamDataSetFormat.Binary);
buffer = stream.ToArray();
}
//Deserialize the DataSet (where 'buffer' is the previous serialized byte[])
System.Data.DataSet deserializedDs = new System.Data.DataSet();
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer))
{
DevAge.Data.StreamDataSet.Read(stream, deserializedDs,
DevAge.Data.StreamDataSetFormat.Binary, true);
}
System.Diagnostics.Debug.Assert(deserializedDs.Tables[0].Rows.Count == 2);
}
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:31,代码来源:GenericTest.cs
示例2: DataTableToExcel
/// <summary>
/// 导出Excel,以旧列名-新列名词典为标头
/// </summary>
/// <param name="dt"></param>
/// <param name="dicCoumnNameMapping"></param>
public static void DataTableToExcel(System.Data.DataTable dt, Dictionary<string, string> dicCoumnNameMapping, string fileName)
{
ExcelHandler eh = new ExcelHandler();
SheetExcelForm frm = new SheetExcelForm();
eh.ProcessHandler = frm.AddProcess;
eh.ProcessErrorHandler = new Action<string>((msg) =>
{
MessageBox.Show(msg);
});
try
{
frm.Show();
Delay(20);
var ds = new System.Data.DataSet();
ds.Tables.Add(dt);
eh.DataSet2Excel(ds, dicCoumnNameMapping, fileName);
ds.Tables.Remove(dt);
ds.Dispose();
}
catch (Exception ex)
{
MessageBox.Show("导出Excel错误:" + ex.Message);
}
finally
{
Delay(20);
frm.Close();
}
}
开发者ID:howbigbobo,项目名称:DailyCode,代码行数:34,代码来源:WinFormExcelExporter.cs
示例3: acquireData
private void acquireData()
{
OdbcConnection conn = new OdbcConnection("Driver={SQL Server Native Client 11.0}; server=jfsql2014;database=d3charting;trusted_connection=yes;");
OdbcCommand cmd = new OdbcCommand("select * from bar_chart;");
conn.Open();
cmd.Connection = conn;
OdbcDataAdapter da = new OdbcDataAdapter();
System.Data.DataSet ds = new System.Data.DataSet();
da.SelectCommand = cmd;
da.Fill(ds);
JSONDocument = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None);
cmd = new OdbcCommand("select T.Product, T.[This Year] as TY, F.Forecast FROM bar_chart T JOIN forecast F ON T.Product = F.Product");
cmd.Connection = conn;
da = new OdbcDataAdapter();
ds = new System.Data.DataSet();
da.SelectCommand = cmd;
da.Fill(ds);
ForecastData = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None);
conn.Close();
}
开发者ID:scardella,项目名称:d3charting,代码行数:26,代码来源:barchart.aspx.cs
示例4: TC_SetDislay
public void TC_SetDislay(System.Data.DataSet ds)
{
checkConntected();
if (ds.Tables[0].Rows[0]["func_name"].ToString() != "set_speed")
throw new Exception("only support func_name = set_speed");
lock (this.currDispLockObj)
{
if (currDisplayds == null)
{
this.InvokeOutPutChangeEvent(this, ds.Tables[0].Rows[0]["speed"].ToString());
}
else
if (currDisplayds.Tables[0].Rows[0]["speed"].ToString() != ds.Tables[0].Rows[0]["speed"].ToString())
this.InvokeOutPutChangeEvent(this, ds.Tables[0].Rows[0]["speed"].ToString());
currDisplayds = ds;
Comm.SendPackage pkg = this.m_protocol.GetSendPackage(ds, 0xffff);
this.Send(pkg);
}
}
开发者ID:ufjl0683,项目名称:Center,代码行数:26,代码来源:CSLSTC.cs
示例5: LoadData
private void LoadData()
{
taskDataAdapter = new System.Data.SQLite.SQLiteDataAdapter("SELECT * FROM events WHERE ID=" + id, connection);
alertsDataAdapter = new System.Data.SQLite.SQLiteDataAdapter("SELECT * FROM events_alerts WHERE event_id=" + id, connection);
dataSet = new System.Data.DataSet();
var taskCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(taskDataAdapter);
var alertsCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(alertsDataAdapter);
taskDataAdapter.Fill(dataSet, "event");
alertsDataAdapter.Fill(dataSet, "alerts");
var parentColumn = dataSet.Tables["event"].Columns["ID"];
{
var childColumn = dataSet.Tables["alerts"].Columns["event_id"];
var relation = new System.Data.DataRelation("event_alerts", parentColumn, childColumn);
dataSet.Relations.Add(relation);
}
//var table = dataSet.Tables["event"];
row = dataSet.Tables["event"].Rows[0];
dataSet.Tables["event"].RowChanged += table_RowChanged;
dataSet.Tables["alerts"].RowChanged += table_RowChanged;
dataSet.Tables["alerts"].RowDeleted += table_RowDeleted;
dataSet.Tables["alerts"].TableNewRow += table_TableNewRow;
FillDeadline(row);
FillTags(id);
TaskGrid.DataContext = dataSet.Tables["event"].DefaultView;
AlertsDataGrid.ItemsSource = dataSet.Tables["alerts"].DefaultView;
}
开发者ID:xeph,项目名称:LOG350.TP3,代码行数:34,代码来源:Events.xaml.cs
示例6: consultaInformacion
//Procedimiento que consulta información definida por parámetros del
//query, retorna un dataset con la información
public System.Data.DataSet consultaInformacion(String queryToExecute)
{
String resultadoOperacion;
System.Data.DataSet sqlDsConsulta = new System.Data.DataSet(); ;
resultadoOperacion = "EXITOSO";
abreConexion();
try
{
//Crea las instancias
this.sqlCmdConsulta = new SqlCommand();
this.sqlDaConsulta = new SqlDataAdapter();
//Construye el comando Select
sqlCmdConsulta.Connection = cnBaseDatos;
sqlCmdConsulta.CommandText = queryToExecute;
sqlCmdConsulta.CommandType = System.Data.CommandType.Text;
sqlDaConsulta.SelectCommand = sqlCmdConsulta;
//Carga el DataSet
this.sqlDaConsulta.Fill(sqlDsConsulta);
}
catch (SqlException exc)
{
//resultadoOperacion = "Error(" & exc.Number.ToString & "): " & exc.Messag;
}
return sqlDsConsulta;
}
开发者ID:dar2608,项目名称:PrograVI,代码行数:29,代码来源:clsConexion.cs
示例7: GetParameter
private System.Data.DataRow GetParameter(string IDParametro, int? IDPortal, int? IDSistema, string IDUsuario)
{
// Aca se lee la informacion de la base de datos
// y se preparan los layers
string connStr = ValidacionSeguridad.Instance.GetSecurityConnectionString();
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connStr);
conn.Open();
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand
("SELECT * FROM dbo.SF_VALOR_PARAMETRO(@IDParametro, @IDPortal, @IDSistema, @IDUsuario)", conn);
System.Data.SqlClient.SqlParameter prm = new System.Data.SqlClient.SqlParameter("@IDParametro", System.Data.SqlDbType.VarChar, 100);
prm.Value = IDParametro;
cmd.Parameters.Add(prm);
prm = new System.Data.SqlClient.SqlParameter("@IDPortal", System.Data.SqlDbType.Int);
if (IDPortal.HasValue)
{
prm.Value = IDPortal.Value;
}
else
{
prm.Value = null;
}
cmd.Parameters.Add(prm);
prm = new System.Data.SqlClient.SqlParameter("@IDSistema", System.Data.SqlDbType.Int);
if (IDSistema.HasValue)
{
prm.Value = IDSistema.Value;
}
else
{
prm.Value = null;
}
cmd.Parameters.Add(prm);
prm = new System.Data.SqlClient.SqlParameter("@IDUsuario", System.Data.SqlDbType.VarChar);
if (IDUsuario != null)
{
prm.Value = IDUsuario;
}
else
{
prm.Value = null;
}
cmd.Parameters.Add(prm);
// IdParametro, Alcance, ValorTexto, ValorEntero, ValorDecimal, ValorLogico, ValorFechaHora
cmd.CommandType = System.Data.CommandType.Text;
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd);
System.Data.DataSet ds = new System.Data.DataSet();
da.Fill(ds);
conn.Close();
return ds.Tables[0].Rows[0];
//return resultado;
}
开发者ID:diegowald,项目名称:intellitrack,代码行数:60,代码来源:UDPHandler.cs
示例8: Process
internal static void Process (List<string> assemblies, string outputPath)
{
List<string> valid_config_files = new List<string> ();
foreach (string assembly in assemblies) {
string assemblyConfig = assembly + ".config";
if (File.Exists (assemblyConfig)) {
XmlDocument doc = new XmlDocument ();
try {
doc.Load (assemblyConfig);
} catch (XmlException) {
doc = null;
}
if (doc != null)
valid_config_files.Add (assemblyConfig);
}
}
if (valid_config_files.Count == 0)
return;
string first_file = valid_config_files [0];
System.Data.DataSet dataset = new System.Data.DataSet ();
dataset.ReadXml (first_file);
valid_config_files.Remove (first_file);
foreach (string config_file in valid_config_files) {
System.Data.DataSet next_dataset = new System.Data.DataSet ();
next_dataset.ReadXml (config_file);
dataset.Merge (next_dataset);
}
dataset.WriteXml (outputPath + ".config");
}
开发者ID:transformersprimeabcxyz,项目名称:cecil-old,代码行数:32,代码来源:ConfigMerger.cs
示例9: EmployeeDataSet
protected EmployeeDataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) :
base(info, context, false) {
if ((this.IsBinarySerialized(info, context) == true)) {
this.InitVars(false);
System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
this.Tables.CollectionChanged += schemaChangedHandler1;
this.Relations.CollectionChanged += schemaChangedHandler1;
return;
}
string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
if ((this.DetermineSchemaSerializationMode(info, context) == System.Data.SchemaSerializationMode.IncludeSchema)) {
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema)));
if ((ds.Tables["employee"] != null)) {
base.Tables.Add(new employeeDataTable(ds.Tables["employee"]));
}
this.DataSetName = ds.DataSetName;
this.Prefix = ds.Prefix;
this.Namespace = ds.Namespace;
this.Locale = ds.Locale;
this.CaseSensitive = ds.CaseSensitive;
this.EnforceConstraints = ds.EnforceConstraints;
this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
this.InitVars();
}
else {
this.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema)));
}
this.GetSerializationData(info, context);
System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
base.Tables.CollectionChanged += schemaChangedHandler;
this.Relations.CollectionChanged += schemaChangedHandler;
}
开发者ID:antklim,项目名称:consumables,代码行数:33,代码来源:EmployeeDataSet.Designer.cs
示例10: listar
public List<Combustivel> listar()
{
List<Combustivel> lista = new List<Combustivel>();
System.Data.DataSet ds = new System.Data.DataSet();
Int32 x = 0;
try
{
SqlDataReader reader;
command.Connection = MsSQL.getConexao();
command.Connection.Open();
vsql.Append("SELECT ID, DESCRICAO FROM COMBUSTIVEL ");
vsql.Append("ORDER BY DESCRICAO ");
command.CommandText = vsql.ToString();
reader = command.ExecuteReader();
while (reader.Read())
{
lista.Add(new Combustivel());
lista[x].ID = Convert.ToInt32(reader["ID"]);
lista[x].Descricao = reader["DESCRICAO"].ToString();
x++;
}
return lista;
}
catch (Exception e)
{
throw new Exception("Erro ao montar a lista de Tipo de combustível. " + e.Message);
}
finally
{
command.Connection.Close();
}
}
开发者ID:chmcorbo,项目名称:App.NET,代码行数:33,代码来源:DAOCombustivel.cs
示例11: GetDataBySql
public static System.Data.DataTable GetDataBySql(string sql)
{
SqlConnection con = new SqlConnection(StrCon); con.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, StrCon); System.Data.DataSet ds = new System.Data.DataSet();
da.Fill(ds); con.Dispose(); con.Close();
return ds.Tables[0];
}
开发者ID:mrk29vn,项目名称:vna-accounting,代码行数:7,代码来源:Connection.cs
示例12: GetAllRecordsFromXML
public void GetAllRecordsFromXML()
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(Server.MapPath("Login.xml"));
GridView1.DataSource = ds;
GridView1.DataBind();
}
开发者ID:pkgod7,项目名称:windowsphone-sprmalaysia,代码行数:7,代码来源:Login.aspx.cs
示例13: SelectFromXLS
/// <summary>
/// 执行查询
/// </summary>
/// <param name="ServerFileName">xls文件路径</param>
/// <param name="SelectSQL">查询SQL语句</param>
/// <returns>DataSet</returns>
public static System.Data.DataSet SelectFromXLS(string ServerFileName, string SelectSQL)
{
string connStr = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + ServerFileName + "';Extended Properties=Excel 8.0";
OleDbConnection conn = new OleDbConnection(connStr);
OleDbDataAdapter da = null;
System.Data.DataSet ds = new System.Data.DataSet();
try
{
conn.Open();
da = new OleDbDataAdapter(SelectSQL, conn);
da.Fill(ds, "SelectResult");
}
catch (Exception e)
{
conn.Close();
throw e;
}
finally
{
conn.Close();
}
return ds;
}
开发者ID:HP-Richard,项目名称:https---github.com-litianbao-GoldenCat,代码行数:31,代码来源:Util_XLS.cs
示例14: TC_SetDislay
public void TC_SetDislay(System.Data.DataSet ds)
{
checkConntected();
string oldDispStr = "";
if (ds.Tables[0].Rows[0]["func_name"].ToString() != "set_ctl_sign")
throw new Exception("only support func_name = set_ctl_sign");
if (this.currDisplayds == null )
{
lock (currDispLockObj)
currDisplayds = ds;
Comm.SendPackage pkg = this.m_protocol.GetSendPackage(ds, 0xffff);
this.Send(pkg);
this.InvokeOutPutChangeEvent(this, this.GetCurrentDisplayDecs());
return;
}
else
oldDispStr = this.GetCurrentDisplayDecs();
lock(currDispLockObj)
currDisplayds = ds;
if (oldDispStr != this.GetCurrentDisplayDecs())
{
Comm.SendPackage pkg = this.m_protocol.GetSendPackage(ds, 0xffff);
this.Send(pkg);
this.InvokeOutPutChangeEvent(this, this.GetCurrentDisplayDecs());
}
}
开发者ID:ufjl0683,项目名称:Center,代码行数:32,代码来源:LCSTC.cs
示例15: Demonstrate
public static void Demonstrate()
{
var myInt = 100;
myInt.DisplayDefiningAssembly();
var ds = new System.Data.DataSet();
ds.DisplayDefiningAssembly();
}
开发者ID:eswise,项目名称:Training,代码行数:8,代码来源:04_ExtensionMethods.cs
示例16: FullDataSet
protected FullDataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) :
base(info, context, false) {
if ((this.IsBinarySerialized(info, context) == true)) {
this.InitVars(false);
System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
this.Tables.CollectionChanged += schemaChangedHandler1;
this.Relations.CollectionChanged += schemaChangedHandler1;
return;
}
string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
if ((this.DetermineSchemaSerializationMode(info, context) == System.Data.SchemaSerializationMode.IncludeSchema)) {
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema)));
if ((ds.Tables["Product"] != null)) {
base.Tables.Add(new ProductDataTable(ds.Tables["Product"]));
}
if ((ds.Tables["Country"] != null)) {
base.Tables.Add(new CountryDataTable(ds.Tables["Country"]));
}
if ((ds.Tables["FarmGroup"] != null)) {
base.Tables.Add(new FarmGroupDataTable(ds.Tables["FarmGroup"]));
}
if ((ds.Tables["FarmGroupLevel2"] != null)) {
base.Tables.Add(new FarmGroupLevel2DataTable(ds.Tables["FarmGroupLevel2"]));
}
if ((ds.Tables["Manufacturer"] != null)) {
base.Tables.Add(new ManufacturerDataTable(ds.Tables["Manufacturer"]));
}
if ((ds.Tables["Packing"] != null)) {
base.Tables.Add(new PackingDataTable(ds.Tables["Packing"]));
}
if ((ds.Tables["StorageCondition"] != null)) {
base.Tables.Add(new StorageConditionDataTable(ds.Tables["StorageCondition"]));
}
if ((ds.Tables["Unit"] != null)) {
base.Tables.Add(new UnitDataTable(ds.Tables["Unit"]));
}
if ((ds.Tables["Substance"] != null)) {
base.Tables.Add(new SubstanceDataTable(ds.Tables["Substance"]));
}
this.DataSetName = ds.DataSetName;
this.Prefix = ds.Prefix;
this.Namespace = ds.Namespace;
this.Locale = ds.Locale;
this.CaseSensitive = ds.CaseSensitive;
this.EnforceConstraints = ds.EnforceConstraints;
this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
this.InitVars();
}
else {
this.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema)));
this.InitExpressions();
}
this.GetSerializationData(info, context);
System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
base.Tables.CollectionChanged += schemaChangedHandler;
this.Relations.CollectionChanged += schemaChangedHandler;
}
开发者ID:vpjulia,项目名称:Salvia,代码行数:58,代码来源:FullDataSet.Designer.cs
示例17: GetDataTable
public static System.Data.DataTable GetDataTable(string sql, System.Data.SqlClient.SqlConnection conn)
{
System.Data.SqlClient.SqlDataAdapter adp = new System.Data.SqlClient.SqlDataAdapter(sql, conn);
adp.MissingSchemaAction = System.Data.MissingSchemaAction.AddWithKey;
System.Data.DataSet ds = new System.Data.DataSet();
adp.Fill(ds);
System.Data.DataTable tbl = ds.Tables[0];
return tbl;
}
开发者ID:viticm,项目名称:pap2,代码行数:9,代码来源:Helper.cs
示例18: NorthwindDataSet
protected NorthwindDataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) :
base(info, context) {
if ((this.IsBinarySerialized(info, context) == true)) {
this.InitVars(false);
System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
this.Tables.CollectionChanged += schemaChangedHandler1;
this.Relations.CollectionChanged += schemaChangedHandler1;
return;
}
string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
if ((strSchema != null)) {
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema)));
if ((ds.Tables["Products"] != null)) {
base.Tables.Add(new ProductsDataTable(ds.Tables["Products"]));
}
if ((ds.Tables["Orders"] != null)) {
base.Tables.Add(new OrdersDataTable(ds.Tables["Orders"]));
}
if ((ds.Tables["Suppliers"] != null)) {
base.Tables.Add(new SuppliersDataTable(ds.Tables["Suppliers"]));
}
if ((ds.Tables["Shippers"] != null)) {
base.Tables.Add(new ShippersDataTable(ds.Tables["Shippers"]));
}
if ((ds.Tables["Customers"] != null)) {
base.Tables.Add(new CustomersDataTable(ds.Tables["Customers"]));
}
if ((ds.Tables["Categories"] != null)) {
base.Tables.Add(new CategoriesDataTable(ds.Tables["Categories"]));
}
if ((ds.Tables["Order Details"] != null)) {
base.Tables.Add(new Order_DetailsDataTable(ds.Tables["Order Details"]));
}
if ((ds.Tables["Employees"] != null)) {
base.Tables.Add(new EmployeesDataTable(ds.Tables["Employees"]));
}
this.DataSetName = ds.DataSetName;
this.Prefix = ds.Prefix;
this.Namespace = ds.Namespace;
this.Locale = ds.Locale;
this.CaseSensitive = ds.CaseSensitive;
this.EnforceConstraints = ds.EnforceConstraints;
this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
this.InitVars();
}
else {
this.BeginInit();
this.InitClass();
this.EndInit();
}
this.GetSerializationData(info, context);
System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
base.Tables.CollectionChanged += schemaChangedHandler;
this.Relations.CollectionChanged += schemaChangedHandler;
}
开发者ID:BackupTheBerlios,项目名称:mbunit-svn,代码行数:56,代码来源:NorthwindDataSet.Designer.cs
示例19: MyDataSet
private System.Data.DataSet MyDataSet()
{
System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(str_con);
con.Open();
da_1 = new System.Data.SqlClient.SqlDataAdapter(SQL_string, con);
System.Data.DataSet data_set = new System.Data.DataSet();
da_1.Fill(data_set, "Test");
con.Close();
return data_set;
}
开发者ID:AmirjohnSanhinov,项目名称:StarKampf,代码行数:10,代码来源:DBCon.cs
示例20: GetBatchData
private string GetBatchData()
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
string resourceName = "Processors.BBPS.CreditCard.Data.BatchData.xml";
using (System.IO.Stream strm = assembly.GetManifestResourceStream(resourceName))
{
System.Data.DataSet orginalBatch = new System.Data.DataSet();
System.Data.DataSet refund = new System.Data.DataSet();
refund.Tables.Add(new System.Data.DataTable());
var x = orginalBatch.ReadXml(strm);
var dr = orginalBatch.Tables[0].CreateDataReader();
refund.Tables[0].Columns.Add(new System.Data.DataColumn("transactionid"));
refund.Tables[0].Columns.Add(new System.Data.DataColumn("referenceTransactionid"));
refund.Tables[0].Columns.Add(new System.Data.DataColumn("amount"));
while (dr.Read())
{
var drow = refund.Tables[0].NewRow();
string refTrxId, amount;
refTrxId = dr.GetString(0);
amount = dr.GetString(6);
drow.ItemArray = new String[] { Guid.NewGuid().ToString(), refTrxId, amount };
refund.Tables[0].Rows.Add(drow);
}
using (System.IO.StringWriter sw = new System.IO.StringWriter(new System.Text.StringBuilder()))
{
List<string> columns = new List<string>();
foreach (System.Data.DataColumn d in refund.Tables[0].Columns)
{
columns.Add(d.ColumnName);
}
sw.WriteLine(string.Join(",", columns.ToArray()));
foreach (System.Data.DataRow _dr in refund.Tables[0].Rows)
{
sw.WriteLine(string.Join(",", _dr.ItemArray));
}
return sw.GetStringBuilder().ToString();
}
}
}
开发者ID:shovelheadfxe,项目名称:DevLab,代码行数:55,代码来源:Batch.cs
注:本文中的System.Data.DataSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论