how to save the XML file into the database

B

buran

Dear ASP.NET Programmers,

I am saving the tables of a dataset into an XML file. I want to save the XML
file into the database, then retireve it as a dataset. I use the following
code:

ds.WriteXml("C:\Inetpub\wwwroot\database2\richtext\burak.xml")

where ds is my dataset.

When the page loads, I want that the contents of the XML file are loaded
into a dataset. I hope, that I could clearly explain what I want. Thanks in
advance,

Buran
 
B

buran

Hi,

First of all, thank you for your help. I think, I managed to save the XML
data into the database and retrieve it from the database. I have the
following problem. When I bind the XML data, which I have read from the
database, to the datalist control, following error message appears:


DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with
the name ExchangeRate.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.DataRowView' does not contain a property with the name
ExchangeRate.

Source Error:


Line 89: <TD align="right" width="10%"><%# Databinder.Eval(Container,
"DataItem.InvoiceNo") %></TD>
Line 90: <TD align="right" width="10%"><%# Databinder.Eval(Container,
"DataItem.InvoiceDate", "{0:d}") %></TD>
Line 91: <TD align="right" width="10%"><%# Databinder.Eval(Container,
"DataItem.ExchangeRate") %></TD>
Line 92: <TD align="right" width="10%"><%# Databinder.Eval(Container,
"DataItem.WithoutUs", "{0:n}") %></TD>
Line 93: <TD align="right" width="10%"><%# Databinder.Eval(Container,
"DataItem.Difference", "{0:n}") %></TD>





I am using the following code blocks:





Private Sub btnSaveCP_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSaveCP.Click

ds = ViewState("ds")
ds.WriteXml("C:\Inetpub\wwwroot\database2\richtext\burak.xml")

Dim strXML As String
strXML = ds.GetXml

strSql = "spNewCoverPage"
myCommand.CommandText = strSql
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Clear()
myCommand.Parameters.Add("@ourFileNo",
Session("selectedFileNumber"))
myCommand.Parameters.Add("@xMLData", strXML)
myCommand.Parameters.Add("@totalAmount", CalculateTotalAmount())
myCommand.Parameters.Add("@totalAmountCurrency", lblCurTotal.Text)
myCommand.Parameters.Add("@createdOn", Date.Now)
myCommand.Parameters.Add("@createdBy", Session("employeeId"))
'Girilen yazýlarý da kaydedelim
myCommand.Parameters.Add("@enteredICAddress",
Server.UrlEncode(txtICAddress.Text))
myCommand.Parameters.Add("@enteredClientName", txtClientName.Text)
If Request.Form.Get("txtItemDesc") <> "" Then
myCommand.Parameters.Add("@enteredItemDesc",
Request.Form.Get("txtItemDesc"))
End If
If Request.Form.Get("txtItem") <> "" Then
myCommand.Parameters.Add("@enteredItem",
Request.Form.Get("txtItem"))
End If
myCommand.Parameters.Add("@enteredDate", CType(txtDate.Text, Date))

myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()

End Sub

'on another page

Dim strXML As String
strXML = myDataSet.Tables(0).Rows(0).Item("XMLData")

Dim strReader As System.IO.StringReader
strReader = New System.IO.StringReader(strXML)

ds.ReadXml(strReader)

dliHospCosts.DataSource = ds
dliHospCosts.DataMember = "HospCosts"
dliHospCosts.DataBind()

How can I solve this? Thanks in advance,

Buran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top