CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2007
    Posts
    1

    Arrow How to create text files and xml files from vb

    Hello friends,
    I have two doubts.
    1.How to create xml file and text files using vb codes?
    2.Is it possible to create xml file direcly from sql server for data sending?.How?

    Thanks in advance,
    Santhosh

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to create text files and xml files from vb

    Download the MSXMLx parser. Think they're up to version 6

    SQL Server 2005 might be able to send xml
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2006
    Posts
    95

    Re: Want to create XML file directly from SQL

    Can you be a bit more specific in what you want?
    What kind of Database? What kind of XML file? How do you want it to be generated/used?
    On Error Kill(User)

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Want to create XML file directly from SQL

    Quote Originally Posted by santhoshabraham
    Hello Friends,
    I Want to create XML file directly from SQL...pls give me some tips for that

    regards,
    Santhosh
    Lookup For "For XML" keyword in books online.

  5. #5
    Join Date
    May 2002
    Posts
    10,943

    Re: How to create text files and xml files from vb

    [ merged ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  6. #6
    Join Date
    Nov 2002
    Posts
    278

    Re: How to create text files and xml files from vb

    Call the function below like this. . . pass it a recordset and it will create an xml file from of the recordset you pass to it. It also returns the recordset completely detached from its datasource.

    Set rsRecordSet = DisconnectRecordSet(rsRecordSet)

    Code:
    Public Function DisconnectRecordSet(rsRecordSetToDisconnect As ADODB.Recordset) As ADODB.Recordset
    
    Dim sPersistedRecordsetFileName As String
    
        On Error GoTo DisconnectRecordSetErrHandler
    
    
        sPersistedRecordsetFileName = App.Path & "\" & App.EXEName & ".xml"
        ' wipmove.xml"
    
        If LenB(Dir(sPersistedRecordsetFileName)) <> 0 Then
            Kill sPersistedRecordsetFileName
        End If
    
        rsRecordSetToDisconnect.Save sPersistedRecordsetFileName, adPersistXML
        rsRecordSetToDisconnect.Close
    
        Set rsRecordSetToDisconnect = Nothing
        Set rsRecordSetToDisconnect = New ADODB.Recordset
    
    
        rsRecordSetToDisconnect.CursorLocation = adUseClient
        rsRecordSetToDisconnect.LockType = adLockBatchOptimistic
        rsRecordSetToDisconnect.Open sPersistedRecordsetFileName
        Set DisconnectRecordSet = rsRecordSetToDisconnect
    
    
    DisconnectRecordSetExitPoint:
        On Error Resume Next
        Exit Function
    
    DisconnectRecordSetErrHandler:
    
        Select Case Err.Number
    
            Case Else
                MsgBox AN_UNEXPECTED_ERROR_OCCURRED_IN & "Globals.DisconnectRecordSet" & vbCrLf & vbCrLf & Err.Description, vbOKOnly + vbExclamation
        End Select
    
    
    
        Resume DisconnectRecordSetExitPoint
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured