Link to home
Start Free TrialLog in
Avatar of Cannibal_Jack
Cannibal_Jack

asked on

Selecting and viewing data from SQL database

I'm not very good with SQL and using it in vb.net. I'm trying to pull all the names of people who are of a certain age...

        Dim conn As New SqlClient.SqlConnection(connString)
        Dim cmdString As String = "Select * from Tbl_Test Where (Age) VALUES (@Age)"
        Dim cmd As New SqlClient.SqlCommand(cmdString, conn)
        With cmd.Parameters
            .Add(New SqlClient.SqlParameter("@Age", TxtAge.Text))
        End With
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()

I get an error pointing to the line with "Values" and it says invalid syntax. Is there a way to fix this? and is there a way someone could show me to display a list of the peoples names who are of the choosen age. any help would be great.
SOLUTION
Avatar of Chris Mangus
Chris Mangus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cannibal_Jack
Cannibal_Jack

ASKER

Thanks, Is there a way to display the results in maybe a message box? in a clean manner like say...

Bob, Dave, Joe, etc

any help would be great, thanks.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial