Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:47:12+00:00 2026-06-17T13:47:12+00:00

I am having problems with code below: For x As Integer = 0 To

  • 0

I am having problems with code below:

 For x As Integer = 0 To family_grid.RowCount

                family_composition = family_grid.Rows(x).Cells(0).Value
                age = family_grid.Rows(x).Cells(1).Value
                status = family_grid.Rows(x).Cells(2).Value
                relation = family_grid.Rows(x).Cells(3).Value
                educational_attainment = family_grid.Rows(x).Cells(4).Value
                occupation = family_grid.Rows(x).Cells(5).Value
                income = family_grid.Rows(x).Cells(6).Value

                dbConnect.Open()
                Dim str1 As String = "INSERT INTO tbl_general_intake_family(id, family_composition, age, status, relation, educational_attainment, occupation, income)values(id, family_composition, age, status, relation, educational_attainment, occupation, income)"
Dim da As New OleDbDataAdapter()
    Dim ds As New DataSet()
                    Dim com As New OleDb.OleDbCommand(str1, dbConnect)
                    com.Parameters.AddWithValue("id", var_document_id)
                    com.Parameters.AddWithValue("family_composition", family_composition)
                    com.Parameters.AddWithValue("age", age)
                    com.Parameters.AddWithValue("status", status)
                    com.Parameters.AddWithValue("relation", relation)
                    com.Parameters.AddWithValue("educational_attainment", educational_attainment)
                    com.Parameters.AddWithValue("occupation", occupation)
                    com.Parameters.AddWithValue("income", income)
                    com.ExecuteNonQuery()
                    com.Dispose()
                    dbConnect.Close()
                Next

The for loop never executes because family_grid.RowCount is returning a value of zero.

In the form_load event, I populate the DataGridView using the following code:

Dim mycon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                    "Data Source=" + My.Application.Info.DirectoryPath + "\mswd-rms.mdb")
                mycon.Open()
                Dim mycomm As New OleDbCommand("SELECT * FROM tbl_general_intake_family WHERE id=" & main_general_intake.document_id, mycon)
                Dim da As New OleDbDataAdapter()
                da.SelectCommand = mycomm
                Dim ds As New DataSet()
                da.Fill(ds)
                family_grid.Columns.Clear()
                family_grid.ReadOnly =  true
                family_grid.DataSource = ds.Tables(0)
                family_grid.Columns(0).HeaderText = "ID"
                family_grid.Columns(1).HeaderText = "Name"
                family_grid.Columns(2).HeaderText = "Age"
                family_grid.Columns(3).HeaderText = "Status"
                family_grid.Columns(4).HeaderText = "Relation"
                family_grid.Columns(5).HeaderText = "Educational Attainment"
                family_grid.Columns(6).HeaderText = "Occupation"
                family_grid.Columns(7).HeaderText = "Income"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:47:13+00:00Added an answer on June 17, 2026 at 1:47 pm

    There is no way the RowCount should be zero given the grid is populated with a single Row in the Form_Load. RowCount should return 1.

    To workaround the issue save the datatable to a private form level variable and use its Row.Count.

    private dtCurrentGrid As DataTable
    
    ..
    
    dtCurrentGrid = ds.Tables(0)
    
    ..
    
     For x As Integer = 0 To dtCurrentGrid.Rows.Count
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems trying to get the code below to output the data
I'm having problems finding out what's wrong with the code below. I have consulted
Could anybody tell me what's wrong with this code below, because I'm having problems
I am having a problem using the signedCMS.decode routine. See the code below. The
I am having a problem with the below code. I am not sure why
I am having a very specific problem in JQuery The code below is used
I'm having problems with some code to create a CDialog based window. The code
I am having problems with this code: <?php $new_value = 'testing'; $con = mysql_connect(localhost,user,pass);
I'm having problems the following code gives me no results. however if I uncomment
I've been having problems with this code I had spent the last 3 hours

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.