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.

Recommended Answers

All 2 Replies

Are you retreiving a large amount of records?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.