Show Search Results In Windows Application Form

I'm new to programming/developing using vb.net in visual studio 2005 and wanted to get some general direction for accomplishing this.  I have a simple computer hardware inventory database I'm trying to create a windows based application for a few users to use for pulling information.

I have a search form with 4 option boxes for search criteria:  first name, last name, employee number, serial number (computer), and a search button.  I'm using a sql server db, and I'm just wondering where to start with creating the code behind for this search box.  Do I use a stored procedure?  I want to return all the information in the record like, Employee's name, location, number, computer, serial, etc...

Any help would be great!  Thanks in advance.
john8694Asked:
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.

Jorge PaulinoIT Pro/DeveloperCommented:
>> Do I use a stored procedure?
You don't have to use it.

Do you want to display in a listview or a datagridview ?
0
Jorge PaulinoIT Pro/DeveloperCommented:
Also do you have any code done it ? If so you can show what you have.
0
john8694Author Commented:
Hi Ipaulino, I guess I'd like to show in a listview to make it look a little better.  Is one view better or prfered over the other?  And I don't have any code attached yet to that form.  
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Jorge PaulinoIT Pro/DeveloperCommented:
Normally I do it this way

Inside a Module

        Public Function GetConnection() As SqlConnection
        Dim SqlServerName As String = "MYSERVER"
        Dim SqlServerDatabase As String = "myDB"
        Dim SqlServerLogin As String = "efw"
        Dim SqlServerPassword As String = "fwefw"

        Dim conn As SqlConnection

        Dim strConn As String = "Data Source=" & SqlServerName & ";Initial Catalog=" & SqlServerDatabase & ";User ID=" & SqlServerLogin & ";Password=" & SqlServerPassword & ";Integrated Security=SSPI;"

        conn = New SqlConnection(strConn)
        Try

            conn.Open()

        Catch SqlEx As SqlException
            MsgBox("Error SQL:" & vbCrLf & vbCrLf & SqlEx.Message, MsgBoxStyle.Critical)

        Catch ex As Exception
            MsgBox("Error message", MsgBoxStyle.Critical)
     
        End Try
        GetConnection = conn
    End Function


    <System.Diagnostics.DebuggerStepThrough()> _
    Public Shared Function ExecuteReader(ByVal query As String) As SqlDataReader
        Dim rdr As SqlDataReader = Nothing
        Dim conn As SqlConnection = GetConnection()

        Try

            Dim cmd As SqlCommand = New SqlCommand(query, conn)

            rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)

        Catch SqlEx As SqlException
            MsgBox("Error SQL:" & vbCrLf & vbCrLf & SqlEx.Message, MsgBoxStyle.Critical)

        Catch ex As Exception
            MsgBox("Error message", MsgBoxStyle.Critical)

        End Try
        ExecuteReader = rdr
    End Function

Then in the Form:
   Imports System.Data
   Imports System.Data.SqlClient

            Dim SQL As String = "SELECT * FROM YourTable WHERE MyField = " & 123 & " ORDER BY Item;"
            Dim dr As SqlDataReader = ExecuteReader(SQL)
            While dr.Read
                              ' Add itens to listview using  dr.Item("Item")
             End While
             dr = Nothing


Do you know how to insert itens in a listview ?

jpaulino
0
john8694Author Commented:
No, I'm sorry I don't.  I will try to insert this code you gave me.  I appreciate the help very much.
0
Jorge PaulinoIT Pro/DeveloperCommented:
You have to add the columns in the listview and then you can see in this topic how to add itens. You can check also another example how get data from sql server.

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22732225.html

Don't forget that you have to change the SQL statement to include all your variables/filters.

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
john8694Author Commented:
Thank you very much.  I have a very good starting point now!
0
Jorge PaulinoIT Pro/DeveloperCommented:
Glad I could help. If you need further help just say it.

jpaulino
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
.NET Programming

From novice to tech pro — start learning today.