65.9K
CodeProject is changing. Read more.
Home

Table Data Exporter

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.58/5 (7 votes)

Jan 24, 2008

CPOL
viewsIcon

33892

downloadIcon

314

The Table Data Exporter creates a SQL script for data in a table.

ExportTable

Introduction

This application will let you script table data into a file. It will create an INSERT statement for each row in your table.

Using the code

The application is written in Visual Studio 2003, and has been tested with SQL Server only. Potentially, the application can work with other databases.

The application uses the DataLink object to connect to the database:

Protected Function EditConnectionString(ByVal sConnectionString As String)
    Try
        Dim oDataLinks As Object = CreateObject("DataLinks")
        Dim cn As Object = CreateObject("ADODB.Connection")
        cn.ConnectionString = sConnectionString
        oDataLinks.hWnd = Me.Handle

        If Not oDataLinks.PromptEdit(cn) Then
            'User pressed cancel button
            Return ""
        End If

        cn.Open()
        Return cn.ConnectionString
    Catch ex As Exception
        MsgBox(ex.Message)
        Return ""
    End Try
End Function