Results 1 to 3 of 3

Thread: [RESOLVED] result variable of records instead of showing only query

  1. #1

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Resolved [RESOLVED] result variable of records instead of showing only query

    Code:
        Private Sub cmdLogin_Click(ByVal sender As System.Object, _
                                   ByVal e As System.EventArgs) Handles cmdLogin.Click
    
            Dim conn As MySqlConnection
    
            conn = New MySqlConnection()
            conn.ConnectionString = "server=" & txtServer.Text & ";" _
              & "user id=" & txtUsername.Text & ";" _
              & "password=" & txtPassword.Text & ";" _
              & "database=db1"
            Dim myCommand As New MySqlCommand
            Dim SQL As String
    
            SQL = "SELECT COUNT(ID) FROM OUTBOX "
            Try
                conn.Open()
                myCommand.Connection = conn
                myCommand.CommandText = SQL
                myCommand.ExecuteNonQuery()
    
                Debug.WriteLine(SQL) '<=====how to show it's result variable of records instead of showing only query
    
                conn.Close()
            Catch myerror As MySqlException
                MessageBox.Show("Error Connecting to Database: " & myerror.Message)
            Finally
                conn.Dispose()
            End Try
    
        End Sub
    i supposed it can show the result of count(ID), in this instant it is the number of records
    count on the OUTBOX so the debug.writeline is RESULT, instead of now it is showing "SELECT COUNT(ID) FROM OUTBOX"
    can anybody help me out this problem? thanks

  2. #2
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Re: result variable of records instead of showing only query

    Declare a variable and write

    var1 = myCommand.ExecuteScalar()

    now print var1.
    thanks
    amrita

  3. #3

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: result variable of records instead of showing only query

    that's it, resolved
    thanks amrita, i really appreciate for your help
    i will be back to rate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width