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.

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by Rachna0309
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.