Click here to Skip to main content
15,920,603 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Private Sub ts_submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ts_submit.Click

Dim sql As String

'sql = "insert into activityreport1 values(" & dtp.Value.ToString("dd-MMM-yyyy") & ",'" & dgv1.Rows(0).Cells(1).Value & "','" & dgv1.Rows(0).Cells(2).Value & "','" & dgv1.Rows(0).Cells(3).Value & "','" & dgv1.Rows(0).Cells(4).Value & "','" & dgv1.Rows(0).Cells(5).Value & "','" & dgv1.Rows(0).Cells(6).Value & "','" & dgv1.Rows(0).Cells(7).Value & "','" & dgv1.Rows(0).Cells(8).Value & "','" & dgv1.Rows(0).Cells(9).Value & "','','','','','','','''','','')"
sql = "insert into activityreports1 values('','" & dgv1.Rows(0).Cells(1).Value & "', '" & dgv1.Rows(0).Cells(2).Value & "', '" & dgv1.Rows(0).Cells(3).Value & "', '" & dgv1.Rows(0).Cells(4).Value & "', '" & dgv1.Rows(0).Cells(5).Value & "', '" & dgv1.Rows(0).Cells(6).Value & "', '" & dgv1.Rows(0).Cells(7).Value & "', '" & dgv1.Rows(0).Cells(8).Value & "', '" & dgv1.Rows(0).Cells(9).Value & "', '" & dgv1.Rows(0).Cells(10).Value & "', '" & dgv1.Rows(0).Cells(11).Value & "', '" & dgv1.Rows(0).Cells(12).Value & "', '" & dgv1.Rows(0).Cells(13).Value & "', '" & dgv1.Rows(0).Cells(14).Value & "', '" & dgv1.Rows(0).Cells(15).Value & "', '" & dgv1.Rows(0).Cells(16).Value & "', '" & dgv1.Rows(0).Cells(17).Value & "', '" & dgv1.Rows(0).Cells(18).Value & "', '" & dgv1.Rows(0).Cells(19).Value & "')"
Dim cmd As New OracleCommand(sql, conn)
cmd.CommandType = CommandType.Text
Dim r As Integer = cmd.ExecuteNonQuery
If r = 0 Then
MsgBox("Failed")
Else
MsgBox("Success")
dgv1.Rows(0).Cells(17).Value = "submitted"
End If
End Sub
Posted

yr datagridview may not have the no of columns or u provided please check the column count or row count of datagridview with this insert query ................and match columns count or row count
 
Share this answer
 
You start the cells at 1 not 0 within each query, so you are looking for 10 columns and then 20 columns
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900