insert datatable into the database using dataadapter insert datatable into the database using dataadapter : To do this your datatable schema to be inserted should match with table schema of database. It will work on all database connection string:

Assuming said above your datatable is dtc then call insertTableinDB(dtc, "teamMaster")


         Public Shared Function insertTableinDB(ByVal dt As DataTable, ByVal mytablename As String) As String

        'Create Connection String
        Dim myquery = "select * from " & mytablename & " limit 1"
        Using connection As New SQLiteConnection(System.Configuration.ConfigurationManager.ConnectionStrings("vindb").ConnectionString)

                '' sqlComm = New SQLiteCommand("select * from gamemaster", connection)
                Dim da As New SQLiteDataAdapter(myquery, connection)
                Dim dcmd As SQLiteCommandBuilder = New SQLiteCommandBuilder(da)
                da.MissingSchemaAction = MissingSchemaAction.AddWithKey
                ''  sqlComm.Dispose()
                insertTableinDB = "ok"

            Catch exp As Exception
                'lbldebug.Text = exp.Message
                insertTableinDB = "Error:" + exp.Message

            End Try
            '' Close Database connection
            '' and Dispose Database objects
        End Using

    End Function


Most Viewed Post

solution for facebook waiting

Connect Sony XPLOD MEX-BT2500 Bluetooth CD Receiver with ur mobile

Crystal Report : Show data horizontally (Left to right) i.e. columns as rows

Google+ Followers