Jump to content

como criar uma consulta


Senior
 Share

Recommended Posts

Dim nome As String = "Nome"
        Dim da As New SqlClient.SqlDataAdapter("Select * from Clientes where nome like '%" & nome & "%'", cnn)
        Dim ds As New DataSet
        da.Fill(ds)
        If ds.Tables(0).Rows.Count = 0 Then
            MsgBox("Sem Clientes")
        Else
            For Each DR As DataRow In ds.Tables(0).Rows
                MsgBox("Encontrado: " & DR("Nome").ToString)
            Next
        End If
Link to comment
Share on other sites

o meu codigo esta a dar erro mas na sei porque,diz que o cnn nao foi declarado

Dim nome As String = "Nomemembro"

        Dim da As New SqlClient.SqlDataAdapter("Select * from membros where nome like '%" & nome & "%'", cnn)

        Dim ds As New DataSet

        da.Fill(ds)

        If ds.Tables(0).Rows.Count = 0 Then

            MsgBox("Sem Clientes")

        Else

            For Each DR As DataRow In ds.Tables(0).Rows

                MsgBox("Encontrado: " & DR("Nome").ToString)

            Next

        End If

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.