变量名'@t_id'已经被声明。变量名在查询批处理或存储过程中必须是唯一的

时间:2016-02-12 06:53:59

标签: mysql vb.net

有人请帮忙!

已声明变量名@t_id。变量名在查询批处理或存储过程中必须是唯一的。

    Dim UD_ConnInsert2 As New Data.SqlClient.SqlConnection
    UD_ConnInsert2.ConnectionString = "Data Source=.;Initial Catalog=meetings;Integrated Security=True"
    UD_ConnInsert2.Open()
    Dim CmdInsert2 As New Data.SqlClient.SqlCommand("INSERT INTO tbl_approvals(T_id, Approval,follow_up,A_deadline) VALUES (@T_id,@Approval,@follow_up,@A_deadline)", UD_ConnInsert2)
    '  For Each row As DataGridViewRow In DGVPO.Rows
    For Each row As DataGridViewRow In DataGridView1.Rows
        ' CmdInsert2.Parameters.Clear()
        With(CmdInsert2)
            .Parameters.Add(New Data.SqlClient.SqlParameter("@t_id", Data.SqlDbType.BigInt)).Value = TextBox1.Text
            .Parameters.Add(New Data.SqlClient.SqlParameter("@Approval", Data.SqlDbType.NVarChar, 50)).Value = row.Cells(0).Value
            .Parameters.Add(New Data.SqlClient.SqlParameter("@follow_up", Data.SqlDbType.NVarChar, 50)).Value = row.Cells(1).Value
            .Parameters.Add(New Data.SqlClient.SqlParameter("@A_deadline", Data.SqlDbType.NChar, 10)).Value = row.Cells(2).Value
        End With
        CmdInsert2.ExecuteNonQuery()
    Next
    UD_ConnInsert2.Close()

0 个答案:

没有答案