Thanks Jwenting I did the indexing and the problem is sorted out. The search is very fast now. Thank you all for your suggestions they really opened my head.

Ok I ran a count query and the table has 10,626,529 records (likely to grow further). I have attached the screen shot of the exception message.

I have tried both suggestions but still times out only that it takes slightly longer now to time out. The Exam_number is a char data type.

Hi there, I have have a challenge with my application. I am developing it using VB.Net and SQL server 2014. My database contains 2k plus records. I used to search and return the results very fast when the database was still small. The problem now is that whenever i try to search, it times out before the search is complete. see my code below. What should my code be to avoid time out and also search very fast?

 'connecting to the database 
                Dim con As New SqlClient.SqlConnection("Server=.\SQLEXPRESS;Initial Catalog=RCS;Integrated Security=True")
                Dim cmd As New SqlCommand()
                cmd.Connection = con
                Dim da As New SqlDataAdapter("select r.Surname, r.First_name, r.Sex, c.type from dbo.cand_results AS r, dbo.centres AS c WHERE r.Centre_code = c.code AND r.Exam_number= '" & TxtLatest.Text & "'", con)
                Dim ds As New DataSet("cand_results")
                da.FillSchema(ds, SchemaType.Source, "cand_results")
                da.Fill(ds, "cand_results")
                Dim tblcand_results As DataTable
                tblcand_results = ds.Tables("cand_results")
                If tblcand_results.Rows.Count = 0 Then
                    MsgBox("Candidate not found!", vbExclamation, "Candidate not found")
                    TxtLatestSurname.Text = ""
                    TxtLatestOther.Text = ""
                    TxtLatestSex.Text = ""

                    Exit Sub
                End If
                Dim drcurrent As DataRow
                For Each drcurrent In tblcand_results.Rows
                    TxtLatestSurname.Text = ds.Tables("cand_results").Rows(inc).Item(0)
                    TxtLatestOther.Text = ds.Tables("cand_results").Rows(inc).Item(1)
                    TxtLatestSex.Text = ds.Tables("cand_results").Rows(inc).Item(2)
                    TxtCentre_type1.Text = ds.Tables("cand_results").Rows(inc).Item(3)
            Catch ex As Exception
            End Try
        End If
    End Sub

Yes "namespace error"

I have two computers (Desktop and laptop), The desktop is my office computer and I have been using it for my application development(Visual basic). I have Visual studio 2013 and SQL Server 2014 installed on both computers. I exported the database from my desktop computer to the laptop and copied the project from the project folder to the project folder of the laptop. I went further on to change the connection string to suit the path of the database on the laptop. The problem am facing now is that some forms cannot fit on the screen of the laptop and I have a NAMESPEC ERROR in my code. Whats is the best way to do this in order for the forms to fit on different screens and the namespec issue?
Thanks in anticipation.

Hello everyone, This is Mike joing DANIWEB from Zambia. I have learnt a lot from this site and i have decided to join and learn more and more. I am new to visual basic programming. Looking forward to learn more from the experts in here.

Thanks I have been looking for this very code. Im new to visual basic and am learning a lot from DANIWEB.