将数据表插入到asp.net中的mysql数据库中

时间:2009-09-09 09:30:18

标签: asp.net mysql datatable

有没有办法在asp.net中将动态生成的数据表插入mysql数据库?

1 个答案:

答案 0 :(得分:2)

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