Searching an SQL Server database in VB.NET

-GSS-

Member
Joined
Jun 23, 2007
Messages
11
Programming Experience
Beginner
I'm making a CRM-like application for a client, and the system stores information on customers, products, etc, via a SQL Server DB.

What I am looking to implement is the ability to search for records. For example, the user types in "John" and selects customers (so only query the customer table). Then the results appear, perhaps in a datagrid, in the same window.

Does anyone know how to do this? I have searched on here and elsewhere
Thanks
 
This is simple to do...

Are you going to be doing this in Winforms or Webforms?

Because what you will will do varies slightly on that. Either way you need to use ADO.NET objects to connect to the database and most likely a datagrid binded to a database. There should be a wealth of information online for this stuff maybe you are using the wrong criteria.
 
This was actually for Winforms but nonetheless I have come across another solution. Thanks anyway!
 
Hi thanks for that.

How could I make a search feature where I can actually choose, from the same form, the database table and form (visually) and then search from there?
 
Hi thanks for that.

How could I make a search feature where I can actually choose, from the same form, the database table and form (visually) and then search from there?

You cant, really. The whole idea of that link, and indeed object oriented programming in general is that you operate on objects of known types, and not swap them round at runtime

"Be able to search for any value in any column of any table in any database anwhere on the LAN" was a requirement I was given in a software spec once. I told the manager to go away and rewrite the spec, because it was crap; the idea of a spec is that it is specific ("Provide a way to search the cutomer table based on last name, licence number or join date") not generic ("Press a button that fixes all problems everywhere including ones we havent thought of")

You get to the situation where, if you want to query any column for any value in any table, what you have is the "Microsoft Access Query Design Grid" -> i.e. a development tool, not a user tool.
 
I think you should rather look at providing option for user to choose predefined queries, for example a combo with option to search for Customer, Product or Order.
 
One of the reasons I ask about this is that I have a book on ADO.NET with VB.NET s/c and it gives the source code and walkthrough to implement this exact feature, but the code doesn't work. Which is rather odd...
 
Back
Top