How to insert 300 records from excel file to SQL server with one SP?

  • Hi all,

    I want to write the code in ASP.net to import 300 record from excel file to a sql server table that use a Stored Procedure.

    Show me please, thank very much.

  • This was removed by the editor as SPAM

  • Look into Data Transformation Services....you can write a DTS package that will import an excel file into a table. You can execute a package from VB.NET like:

    Public Function ExecuteDTSPackage() As Boolean

    Dim boolResult As Boolean = True ' Return result

    Dim pkg As DTS.Package ' SQL DTS Package

    ' Try to catch any exceptions

    Try

    ' Create a new SQL DTS Package instance

    pkg = New DTS.Package

    ' Load the Package

    pkg.LoadFromSQLServer("MySQlServer", "sa", "password", _

    DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _

    "", "", "", "ExportCISToGIS",

    Nothing)

    ' Execute the package

    pkg.Execute()

    ' Catch any exceptions

    Catch ex As Exception

    ' On exception set result to false

    boolResult = False

    ' Set last Error

    m_strLastError = ex.Message

    End Try

    Return boolResult ' Return result

    End Function

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply