mysql - 我的代码没有将数据值存储到 Sql 数据库中

标签 mysql vb.net

我编写了一个代码将文本框的值存储到sql数据库中,它工作正常,但是当我尝试将datagridview的值插入sql数据库时,它既不起作用也没有返回错误......

Private Sub savenprint()
        If Not db.con.State = ConnectionState.Open Then
            db.dbOpen()
            With db.cmd
                .Connection = db.con
                .CommandText = "INSERT INTO Reciept VALUES ('" & txtRecieptNo.Text & "','" & TransDate.Text & "','" & txtSubTotal.Text & "') "
                .ExecuteNonQuery()
            End With
            'to save data of DGVOrderedList into RecieptDescription
            For Each row As DataGridViewRow In DGVorderedList.Rows

                MsgBox(row.Cells(1).Value)
                With db.cmd
                    .Connection = db.con
                    .CommandText = "INSERT INTO billDescription VALUES ('" & Val(txtRecieptNo.Text) & "','" & row.Cells(1).Value & "','" & row.Cells(2).Value & "','" & row.Cells(4).Value & "','" & row.Cells(3).Value & "','" & row.Cells(5).Value & "')"
                End With
                MsgBox("Record Saved!")
            Next



        End If
        db.dbClose()
    End Sub

最佳答案

            With db.cmd
                .Connection = db.con
                .CommandText = "INSERT INTO billDescription VALUES ('" & Val(txtRecieptNo.Text) & "','" & row.Cells(1).Value & "','" & row.Cells(2).Value & "','" & row.Cells(4).Value & "','" & row.Cells(3).Value & "','" & row.Cells(5).Value & "')"
                .ExecuteNonQuery()
            End With

关于mysql - 我的代码没有将数据值存储到 Sql 数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41866831/

相关文章:

MySQL规范化存储过程性能

MySQL :Select last 10 entry with column value TRUE and 10 witt value FALSE without repeating

php mysql 显示好友的帖子

vb.net - OCX控制: Sub New() is not accessible in this context because it is 'Private'

vb.net - 使用 "SendMessage"(vb.net) 发送应用程序击键

Java - 'field list' jdbc 错误中的未知列

Mysql子查询优化

c# - 静态关键字正确使用?

vb.net - 捕获Access DB错误(FormatException)并返回自定义消息?

.net - vb.net boolean 值和无