S
saturnius
Hello, I have to save the data from a gridview as XML file. The code is
shown below. Is there no easier way? I would like to access either
asp:SqlDataSource (me.SqlDataSource1.something) or asp:GridView
(me.GridView1.something) instead I have to create a new
sqlcon,selectcommand,dataset,dataadapter....
Is there no easier way?
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
'too much code?
Dim conSave As New
System.Data.SqlClient.SqlConnection(Me.SqlDataSource1.ConnectionString)
conSave.Open()
Dim strSQL As String
Dim dsSave As New Data.DataSet
Dim daSave As New Data.SqlClient.SqlDataAdapter
strSQL = Me.SqlDataSource1.SelectCommand.ToString
daSave.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL,
conSave)
daSave.Fill(dsSave)
'too much code!
dsSave.WriteXml("C:\SomeXMLFile.xml")
End Sub
shown below. Is there no easier way? I would like to access either
asp:SqlDataSource (me.SqlDataSource1.something) or asp:GridView
(me.GridView1.something) instead I have to create a new
sqlcon,selectcommand,dataset,dataadapter....
Is there no easier way?
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
'too much code?
Dim conSave As New
System.Data.SqlClient.SqlConnection(Me.SqlDataSource1.ConnectionString)
conSave.Open()
Dim strSQL As String
Dim dsSave As New Data.DataSet
Dim daSave As New Data.SqlClient.SqlDataAdapter
strSQL = Me.SqlDataSource1.SelectCommand.ToString
daSave.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL,
conSave)
daSave.Fill(dsSave)
'too much code!
dsSave.WriteXml("C:\SomeXMLFile.xml")
End Sub