Dim lastRow = dtc.Rows.Cast(Of DataRow)().LastOrDefault() Dim I As Integer = 0 I += 1 Dim laststr As String = lastRow.Item("ID").ToString + I 'This is for personal information input Using sqlconn As New SqlConnection("SQLstring") Using da As New SqlDataAdapter(String.Empty, sqlconn) Dim sql As New StringBuilder("insert into [") sql.Append(TreeView1.SelectedNode.Text.Replace("]", "\]")) sql.Append("] (") Dim sql1 As New StringBuilder("") Dim andRequired As Boolean = False If datat.Columns.Contains("ID") Then If andRequired Then sql.Append(", ") sql1.Append(", ") End If sql.Append("[Individual_ID]") sql1.Append(laststr) andRequired = True End If sql.AppendFormat(") Select " + sql1.ToString + " from table2") da.SelectCommand.CommandText = sql.ToString() MessageBox.Show(sql.ToString) da.Fill(datat) End Using End Using
Dim I As Integer = 0 I += 1 Dim laststr As String = lastRow.Item("ID").ToString + I
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)