ACP
ACP

Reputation: 35264

Insert a Datatable into mysql database in asp.net

Is there a way to insert a dynamically generated datatable into mysql database in asp.net?

Upvotes: 0

Views: 4729

Answers (1)

user177867
user177867

Reputation:

Sub OutputQty(ByVal dt As DataTable, ByVal AdID As Integer)
    Dim sql As String = ""
    Dim con As New SqlConnection(Utilities.DELcon)
    Dim cmd As New SqlCommand(sql, con)
    con.Open()
    For Each row In dt.Rows
        sql = "INSERT INTO DMQtyOutput (AdID, CompanyID, StoreNumber, DemandQty) VALUES ('" & row("AdID") & "','" & row("CompanyID") & "','" & row("StoreNumber") & "','" & row("DemandQty") & "')"
        cmd.CommandText = sql
        cmd.ExecuteNonQuery()
    Next
    con.Close()
End Sub

Upvotes: 2

Related Questions