I have a SQL Server 2005 datbase table with the following structure:
I want to insert items from a listbox in a WinForms app (VB.Net) into the table using the ordinal position of the item as the FormOrder. I can get the correct position by using the selectedindex + 1but since I'm inserting several rows at a time, I'm not selecting anything.The NavCode field is the same for all inserted records. Here's the code:
If cn.State = ConnectionState.Closed Then
Dim strNavCode As String = txtNavCode.Text
Dim strForm As String = ""
Dim intOrder As Integer =""
Dim strSelect As String = ""
Dim sqlDA As New SqlClient.SqlDataAdapter(strSelect, cn)
If lbWorkflow.Items.Count > 0 Then
For Each strForm In lbWorkflow.Items
strSelect = "INSERT INTO tblWorkflows (NavCode, FormOrder, FormName)" & _
" VALUES ('" & strNavCode & "','" & intOrder & "','" & strForm & "')"
sqlDA.SelectCommand.CommandText = strSelect
Catch err As SqlException
How do I set the ordinal position of each item as FormOrder during the Insert query?