อยากรู้วิธีการนำ file xml เข้าสู่ DATABASE SQL sever2008 ผมต้องทำอย่างไร พี่ๆ ช่วยแนะนำให้หน่อยนะคับ
ประมาณนั้นครับ ใช้การอ่านเป็น DataSet ได้กันแบบง่าย ๆ
Code (VB.NET)
Sub Page_Load(sender As Object, e As EventArgs)
Dim ds As New DataSet
ds.ReadXml(MapPath("customer.xml"))
'*** BindData to DataGrid ***'
myDataGrid.DataSource = ds
myDataGrid.DataBind()
End Sub
Date :
2012-06-19 16:16:55
By :
mr.win
ขอบคุณคับพี่วิน
Date :
2012-06-20 11:16:30
By :
computerpsu031
แบบมีเงื่อนไข
Code (C#)
summaryPath = string.Format("{0}\\xml\\summary.xml", System.Windows.Forms.Application.StartupPath);
unmatchPath = string.Format("{0}\\xml\\unmatch.xml", System.Windows.Forms.Application.StartupPath);
DataTable dtUnmatch = new DataTable();
dtUnmatch.Columns.Add(new DataColumn("Index", typeof(int)));
dtUnmatch.Columns.Add(new DataColumn("InvoiceNo", typeof(string)));
dtUnmatch.Columns.Add(new DataColumn("CustomerName", typeof(string)));
dtUnmatch.Columns.Add(new DataColumn("Amount", typeof(double)));
dtUnmatch.Columns.Add(new DataColumn("Discount", typeof(double)));
dtUnmatch.Columns.Add(new DataColumn("Balance", typeof(double)));
dtUnmatch.Columns.Add(new DataColumn("Vat", typeof(double)));
int index = 1;
(from xu in XElement.Load(unmatchPath).Elements("Unmatch")
join xs in XElement.Load(summaryPath).Elements("Summary") on xu.Element("InvoiceNo").Value equals xs.Element("InvoiceNo").Value
where xu.Element("Solution").Value == key
orderby Convert.ToDouble(xu.Element("Differance").Value) descending
select new
{
Index = index++,
InvoiceNo = xu.Element("InvoiceNo").Value,
CustomerName = xs.Element("CustomerName").Value,
Amount = Convert.ToDouble(xs.Element("Amount").Value),
Discount = Convert.ToDouble(xs.Element("Discount").Value),
Balance = Convert.ToDouble(xs.Element("Balance").Value),
Vat = Convert.ToDouble(xs.Element("Vat").Value)
}).Select(u =>
{
DataRow drNew = dtUnmatch.NewRow();
drNew["Index"] = u.Index;
drNew["InvoiceNo"] = u.InvoiceNo;
drNew["CustomerName"] = u.CustomerName;
drNew["Amount"] = u.Amount;
drNew["Discount"] = u.Discount;
drNew["Balance"] = u.Balance;
drNew["Vat"] = u.Vat;
return drNew;
}).CopyToDataTable(dtUnmatch, LoadOption.PreserveChanges);
dataGridView1.DataSource = dtUnmatch;
Date :
2012-06-20 12:21:09
By :
พี่หมี
Load balance : Server 00