1,105,585 Community Members

adapter.fill takes too long to execute

Member Avatar
Rachna0309
Light Poster
36 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
Dim Con As OdbcConnection = New OdbcConnection
        query = "Select Part_No,SLNOINPART,House_No,SurName+ ' '+F_Name+ ' '+M_Name As Name,Sex,Age,LocalityId from datafile where (Part_No between " & txtPartFrom.Text & " and " & txtPartTo.Text & ") and (age between " & txtAgeFrom.Text & " and " & txtAgeTo.Text & ") order by Part_No"

        Con.ConnectionString = connstring
        Dim da As OdbcDataAdapter = New OdbcDataAdapter(query, Con)
        da.Fill(ds, "Agegroup")
        If ds.Tables("Agegroup").Rows.Count = 0 Then
            MsgBox("No records found.")
        Else
            dgvAgeGroupDetails.DataSource = ds.Tables("Agegroup")

Da.fill(ds,"Agegroup") takes too long to execute.I tried the sql query in access,it executes in 2-3 secs but here in vb.net ,it takes 2-3 mins.Does any1 know the reason behind this?Please help me.

Member Avatar
Begginnerdev
Veteran Poster
1,142 posts since Apr 2010
Reputation Points: 251 [?]
Q&As Helped to Solve: 191 [?]
Skill Endorsements: 15 [?]
 
0
 

Are you retreiving a large amount of records?

Member Avatar
Rachna0309
Light Poster
36 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Solution is: In where clause of query,the fields that are used should be indexed so that searching can be done faster.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article