Hi,

I have a web form in vb that I am writing and I am stuck on getting th evalue of one cell in a row when the checkbox is checked so that I can insert that value into a table in an access database.
Can anybody help on this?
I have spent a couple of days on this already and have gotten nowhere. I have looked at dozens of examples and a few tutorials, but nothing works.
Thanks

I have this basically working, but I have some issues that I am still working on here. There are five columns in the table that need to be updated. With the current statement, I get an error:

Number of query values and destination fields are not the same.

I need to have a minimum of 1 and a maximum of 5 checkboxes checked to update the database. I have not been able to get an update statement to function correctly - I am just doing something wrong, but not sure what.
Can anyone help with the gridview checkbox validation and with the sql update statement?
Thanks in advance

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim command2 As String = "DELETE * from [Selections]"
        
        Dim command As String = "insert into [Selections] ([Selection1], [Selection2], [Selection3], [Selection4], [Selection5]) VALUES("
        For Each gvRow As GridViewRow In GridView1.Rows 'itterate tru all rows  
            Dim chkBox As CheckBox = CType(gvRow.FindControl("chkBox"), CheckBox)
            If chkBox.Checked Then
                command &= "'" & gvRow.Cells(1).Text & "',"
            Else
                command &= ""
                Dim ID = CType(gvRow.Cells(1).Text, String)
            End If
        Next
        command &= ")"
        command = command.Replace(",)", ")") 'replacing the last ,) to only )  
        Response.Write(command2)
        Response.Write(command)
        Dim sqlcon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[connectionstring]")
        Dim sqlComm2 As New OleDbCommand()
        sqlComm2.Connection = sqlcon
        sqlComm2.CommandText = command2
        Dim sqlComm As New OleDbCommand()
        sqlComm.Connection = sqlcon
        sqlComm.CommandText = command

        Using (sqlcon)
            sqlcon.Open()
            sqlComm2.ExecuteNonQuery()
            sqlComm.ExecuteNonQuery()
        End Using
        
    End Sub

Hi,

Show your grid view mark up code and let us know what data you have in the grid view

exception says you supplying less number of parameters..

please map your parameter correctly while writing a query..

Thank you. The gridview code is posted below.
DNANetwork - that is the problem - I apparently do not know how to write it correctly. That is why I am asking for help. Can you give me an example?

<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" 
                 BackColor="White" BorderColor="Blue" BorderStyle="Solid" BorderWidth="1px" 
                 CellPadding="1" DataSourceID="DataSource1" EmptyDataText="N/A" 
                 Font-Names="Arial" Font-Size="XX-Small" ForeColor="#333333" Height="15px" 
                 HorizontalAlign="Center" ShowFooter="True" Width="95%"><RowStyle 
                     BackColor="#F7F6F3" BorderColor="Blue" BorderStyle="Solid" BorderWidth="1px" 
                     Font-Names="Arial" Font-Size="XX-Small" ForeColor="#333333" 
                     HorizontalAlign="Center" VerticalAlign="Middle" Width="6%" /><EmptyDataRowStyle 
                     HorizontalAlign="Center" VerticalAlign="Middle" Width="6%" /><Columns><asp:TemplateField 
                         HeaderText="Compare"><ItemTemplate><asp:CheckBox ID="chkbox" 
                             runat="server" /></ItemTemplate></asp:TemplateField><asp:BoundField 
                         DataField="PlanID" HeaderText="PlanID" SortExpression="PlanID" /><asp:ImageField 
                         DataImageUrlField="Logo" HeaderText="Company"></asp:ImageField><asp:BoundField 
                         DataField="Plan_Name" HeaderText="Plan Name" SortExpression="Plan_Name" /><asp:BoundField 
                         DataField="Monthly" DataFormatString="{0:c}" 
                         HeaderText="Monthly" HtmlEncode="False" ReadOnly="True" 
                         SortExpression="Monthly" /><asp:BoundField 
                         DataField="Individual" HeaderText="Individual" 
                         SortExpression="Individual" /><asp:BoundField 
                         DataField="Features" HeaderText="Features" 
                         SortExpression="Features" /><asp:BoundField 
                         DataField="Enhanced" HeaderText="Enhanced" 
                         SortExpression="Enhanced" /><asp:BoundField 
                         DataField="Accident" HeaderText="Accident" 
                         SortExpression="Accident" /><asp:BoundField DataField="Card" 
                         HeaderText="Card" SortExpression="Card" /><asp:BoundField 
                         DataField="column1" HeaderText="Network" 
                         SortExpression="column1" /><asp:BoundField DataField="column2" 
                         HeaderText="Maximum" SortExpression="column2" /><asp:BoundField 
                         DataField="column3" HeaderText="Out Of Network" 
                         SortExpression="column3" /><asp:BoundField DataField="column4" 
                         HeaderText="Out Of Network" SortExpression="column4" /></Columns><FooterStyle 
                     BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Width="6%" /><PagerStyle 
                     BackColor="#284775" ForeColor="White" HorizontalAlign="Center" Width="6%" /><SelectedRowStyle 
                     BackColor="#E2DED6" BorderColor="Blue" BorderWidth="2px" Font-Bold="True" 
                     Font-Names="Arial" Font-Size="XX-Small" ForeColor="#333333" 
                     HorizontalAlign="Center" VerticalAlign="Middle" Width="6%" /><HeaderStyle 
                     BackColor="#cfdfef" BorderColor="Blue" BorderStyle="Solid" BorderWidth="1px" 
                     Font-Bold="False" Font-Names="Arial" Font-Size="X-Small" ForeColor="Black" 
                     Height="40px" HorizontalAlign="Center" VerticalAlign="Middle" Width="6%" /><EditRowStyle 
                     BackColor="#999999" BorderColor="Black" BorderStyle="Solid" BorderWidth="3px" 
                     Font-Names="Arial" Font-Size="XX-Small" ForeColor="Black" 
                     HorizontalAlign="Center" VerticalAlign="Middle" Width="6%" /><AlternatingRowStyle 
                     BackColor="White" BorderColor="Blue" BorderStyle="Solid" BorderWidth="1px" 
                     Font-Names="Arial" Font-Size="XX-Small" ForeColor="Black" 
                     HorizontalAlign="Center" VerticalAlign="Middle" Width="6%" /></asp:GridView>