我有下面的函数(代码)在DB中插入一些数据,但我想知道如何使用CheckBox将其更改为从DataGridView插入多个记录。我不想失去我的功能 - Public Function Pagamentos() 但是,集成一种方法来插入datagridview中多个选定数据的数据
Public Function Pagamentos() As Boolean
Dim cd As New NpgSqlCommand
Dim query As String = ""
Try
query &= " INSERT INTO Caixa (Recibo, CentroCusto, Data, Dia, Mes, Ano, CentroCustoResumo,DescricaoCentroCusto,CodSubCentroCusto,DescSubCentroCusto,Eventos,Historico,Dinheiro,Cheque,Cartao,DepositoDireto,Total) "
query &= String.Format(" VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}') ", iRecibo, sCentroCusto, sData, sDia, sMes, sAno, sCentroCustoResumo, sDescricaoCentroCusto, sCodSubCentroCusto, sDescSubCentroCusto, sEventos, sHistorico, sDinheiro, sCheque, sCartao, sDepositoDireto, sTotal)
cd.CommandText = query
cd.CommandType = CommandType.Text
If Conexao.NonQuery(cd) Then
sStatus = "Dados do Recibo " & iRecibo & " inserido com sucesso!"
Return True
End If
Catch ex As Exception
sStatus = ex.Message
End Try
Return True
End Function