Urgent - How to use Alphabetical anchor tags to search in the database in an asp.net application with vb.net coding?

I have a search form which will have alphabetical listing in the main form.

When the user clicks on a specific alphabet it should search in the database for that particular alphabet and brings the results as a datagrid of the lastnames which will starts with that alphabet and should display as a separate page.

How can I accomplish this task?

Mine is a ASP.net application and I am using VB.net for my coding.  Please help
amruthanetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fizchCommented:
Your alphabetic link should open a new window passing the indicated letter in either the query string or hiding it in the form and use a parent / child relationship (probably not the right terminology) to access the variable. In this window will be a page that you create that queries the database and binds the results to the dataset.


Your links should look something like this:
 <a href="myResultspage.aspx?LetterId=a" target=_blank>A</a>
 <a href="myResultspage.aspx?LetterId=b" target=_blank>B</a>
 <a href="myResultspage.aspx?LetterId=c" target=_blank>C</a>
 <a href="myResultspage.aspx?LetterId=d" target=_blank>D</a>
etc...

MyResults should do something like this:

  Dim lastInitial as string
  try
     lastInitial = Request.QueryString("LetterId")
     dim sSql as string = "SELECT LastName FROM myTable WHERE LastName LIKE '" & lastInitial & "%'"

     dim myConnection as new SqlConnection (connectionString)
     dim myCommand as new SqlCommand(sSql, myConnection)

     myConnection.Open
     
     dim myReader as SqlDataReader = myCommand.ExecuteReader()

    myDataGrid.DataSource = myReader
    myDataGrid.DataBind()
  catch
    ' this try catch block will catch problems with the database connections
    ' you should put in logic to make sure the data in the query string is what you are expecting
  end try
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amruthanetAuthor Commented:
Thanks.  It is working fine.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.