Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Public Class Site
Dim objConn As SqlConnection = New SqlConnection("Data Source=localhost;Initial Catalog=xxx;User ID=xxx;Password=xxx")
Public Function GoogleSiteMap() As DataSet
Dim dsSiteMapData As New DataSet("SiteMapData")
Dim errorMessages As New StringBuilder()
Try
Dim objCmd As SqlCommand = New SqlCommand("Get_SiteMapData", objConn)
objCmd.CommandType = CommandType.StoredProcedure
objConn.Open()
objCmd.ExecuteNonQuery()
Dim objDA As New SqlDataAdapter(objCmd)
objDA.Fill(dsSiteMapData, "url")
Catch ex As SqlException
Dim i As Integer
For i = 0 To ex.Errors.Count - 1
errorMessages.Append("Index #" & i.ToString() & ControlChars.NewLine _
& "Message: " & ex.Errors(i).Message & ControlChars.NewLine _
& "LineNumber: " & ex.Errors(i).LineNumber & ControlChars.NewLine _
& "Source: " & ex.Errors(i).Source & ControlChars.NewLine _
& "Procedure: " & ex.Errors(i).Procedure & ControlChars.NewLine)
Next i
Console.WriteLine(errorMessages.ToString())
Finally
objConn.Close()
End Try
Return dsSiteMapData
End Function
End Class
End Module
Module Module1
Sub Main()
Dim s As New Site()
s.GoogleSiteMap.WriteXml(System.IO.Path.GetFullPath("SiteMap.xml"), XmlWriteMode.IgnoreSchema)
End Sub
End Module
|