Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any easy way to create an XML table
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00709062
Message ID:
00709901
Views:
26
Here are some steps to do what you are looking for:

Add to your project, a reference to the "System.Web" assembly. Use the Solution Manager to do this.

At the top of your code page put the following imports statements:
Imports System.Data.SqlClient
Imports System.Web.Mail
Use the following sample code to extract the data and send the email. You will need to modify it to fit your situation:
'Connect to the data base and get the table
Dim MyConnectionString As String = "data source=localhost;initial catalog=Northwind;integrated security=SSPI"
Dim oConn As New SqlConnection(MyConnectionString)
Dim dataSet As New DataSet()
Dim getTable As New SqlDataAdapter("select * from customers", oConn)
getTable.Fill(dataSet, "MyTable")
dataSet.WriteXml("C:\MyXMLFile.xml")

Dim Email As New MailMessage()
Email.BodyFormat = MailFormat.Html
Email.BodyEncoding = System.Text.Encoding.Unicode
Email.Body = "My Body Text"
Email.From = "myfromemail@yourcompany.com"
Email.To = "mytoemail@theircompany.com"
Email.Subject = "My Subject line"
Dim XMLFile As New MailAttachment("C:\MyXMLFile.xml", MailEncoding.Base64)
Email.Attachments.Add(XMLFile)
SmtpMail.Send(Email)
Compile the project into an EXE.

To launch the EXE with schedule, you can put it in the task scheduler. You can open task scheduler by choosing [Start menu]->[settings]->[control panel]->[scheduled Tasks].


>Hi Cathi,
>
>New to VB and .net. Its been a big undertaking on my part to try to learn SQL, vb and .net. I really appreciate all the help I can get.
>
>Actually I would like to write a vb program to write the XML file to a directory on the server which would be run on a daily schedule and then schedule a way to ftp or email the file after the XML has been created or n one step if possible. Any easy solutions?
>
>Thanks a lot for your help....
>Roland
>
>===========================================================================
>
>>Are you saying you want to generate an XML file from a SQL Select statement? Are you using a DataSet inside of your Windows Form now? If so, then you can output the DataSet directly to XML using the GetXml method or the WriteXml method.
>>
>>>Hi,
>>>
>>>I need to create an XML Table from a Windows Form using an SQL table as the source.
>>>
>>>Know very little about XML.
>>>
>>>SELECT ClientNum, LastName, FirstName, SignificantOther, Address, City, State, ZipCode, AddressAfterClose, CityAfterClose, StateAfterClose, ZipAfterClose, HomePhone, WorkPhone, WorkPhoneExt, CellPhone, FaxNumber, EmailAddress, Comments, InsertDateTime FROM dbo.Client WHERE (LastName LIKE ?)
>>>
>>>How would I create the XML table with the result rows?
>>>
>>>Thanks
>>>Roland
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform