在mysql查询浏览器数据库中保存listview数据

时间:2011-11-17 03:04:26

标签: mysql vb.net mysql-connector

    Dim lvitem As Object
    Dim iCount As Integer
    Dim iLoop As Integer
    Dim query3 = New SqlCommand
    query3.Connection = New SqlConnection("SERVER=localhost;UID=root;DATABASE=test;")
    iCount = lvLogs.Items.Count()
    If Not lvLogs.Items.Count = 0 Then
        Do Until iLoop = lvLogs.Items.Count
            lvitem = lvLogs.Items.Item(iLoop)
            With LvItem
                query3.CommandText = "insert into wer(CustomerName,SalesGroup,CustomerType,TypeOfIndustry,RM,SeniorRM) values('" & .SubItems(0).Text & "','" & .SubItems(1).Text & "','" & .SubItems(2).Text & "','" & .SubItems(3).Text & "','" & .SubItems(4).Text & "','" & .SubItems(5).Text & "')"
                query3.ExecuteNonQuery()
            End With
            iLoop = iLoop + 1
            LvItem = Nothing
        Loop
    End If
    MessageBox.Show("Record Saved!")

这是我的代码。消息框显示但记录未保存在我的数据库中。请帮帮我

1 个答案:

答案 0 :(得分:1)

您无法使用SqlClient提供商。您必须使用MySql .net连接器API并查看MySql connector examples