Hi
I am having trouble when I am running the below code. I a datagridview (DG) and it has one column that is a DataGridViewComboBoxColumn and this gets populated from a list in a database.
I want to go through all the lines in the DG and add them to a SQL insert statement
Im not quite sure if I am going about this right but any help would be great.Code:Dim RN As String = "Show Cell Address" Try Dim tempsql As String = "" Dim sqli As SqlCommand = sqlconn.CreateCommand Dim Counter As Integer = 0 For Each item In DG.Rows Dim temp As String = "Insert into ConvLookup (JobID,RecordID,FieldName,FieldData) values '" & ConvertID.ToString & "','" & RecordID.ToString & "','" & Counter.ToString & "','" & DG.Item(0, item).Value & "'" tempsql = +temp Counter = +1 Console.WriteLine(DG.Item(0, item).Value.ToString) Next sqli.CommandText = tempsql sqli.ExecuteNonQuery() Catch ex As Exception MsgBox("Error " & vbCrLf & RN & ex.Message) End Try
thanks
Alan




Reply With Quote
