Jump to content
Sign in to follow this  
debliu

Dúvida sobre SELECT em Access

Recommended Posts

Asgorath

Boas.

Usas o ExecuteReader()


"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Share this post


Link to post
Share on other sites
Hellblazer

Por acaso não conheço muito bem acess mas nao terá o Access algo tipo o rownum? seria mais interessante seleccionares tipo o rownum 2 e depois um executescalar :) vou investigar :)


There are two ways to write error-free programs; only the third one works.

Share this post


Link to post
Share on other sites
Hellblazer

Não econtrei melhor tipo de solução :S ve se este codigo funciona :) meti a função a retornar um objecto porque nao sei que tipo de dados queres apanhar.

Imports System.Data.OleDb

Public Function GetSecondValue(ByVal strSQL As String, ByVal strConnectionString As String) As Object

        Dim myConnection As OleDbConnection
        Dim myCommand As OleDbCommand
        Dim dr As OleDbDataReader
        Dim i As Integer = 0
        Dim ObjectReturn As Object
        myConnection = New OleDbConnection(strConnectionString)
        Try
            myConnection.Open()
            If myConnection.State = ConnectionState.Open Then
                myCommand = New OleDbCommand(strSQL, myConnection)
                dr = myCommand.ExecuteReader()
                While dr.Read()
                    If i = 1 Then
                        ObjectReturn = dr(0)
                    End If
                    i += 1
                End While
                dr.Close()
                myConnection.Close()
            Else
                MessageBox.Show("Não se conectou.", "Aviso")
            End If



        Catch e As Exception

        End Try

        Return ObjectReturn

    End Function


There are two ways to write error-free programs; only the third one works.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • 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.