FUNCTION

PARREIRA 04/05/2010 10:28:23
#340855
Bom dia a todos

Fiz essa rotina para mim,porem ela não chamando a minha function,alguem sabe aonde pode estar o erro?

Imports System.Data
Imports System.Data.SqlClient


Public Class Form1
Private Cont As Byte = 0
Private tmp_internet As String


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
RELOGIO.Text = Format(Now, [Ô]hh:MM:ss[Ô])

If Cont <= 30 Then
Cont += 1
Else
tmp_internet = Consulta(7)

If tmp_internet > Now.Minute - 10 Then
IPIRANGA.BackColor = Color.Red
ElseIf tmp_internet > Now.Minute - 5 And tmp_internet < Now.Minute - 10 Then
IPIRANGA.BackColor = Color.Yellow
Else
IPIRANGA.BackColor = Color.Green
End If


End If
End Sub

Private Function Consulta(ByVal Id As Integer) As String
Dim sqlConn As SqlConnection
Dim sqlCmd As SqlCommand
Dim Retorno As String
Try
sqlConn = New SqlConnection([Ô]Data Source=CONTROLADOR;Initial Catalog=distribution;User ID=sa;Password=rerQ7GcN8ii[Ô])
sqlCmd = New SqlCommand
sqlCmd.CommandType = CommandType.Text
sqlCmd.CommandText = [Ô]Select Top 1 End_Time From MSmerge_sessions Where runStatus = 2 Agente_Id = [Ô] & Id.ToString & [Ô] Order By End_Time Desc[Ô]

sqlCmd.Connection = sqlConn

sqlConn.Open()

Retorno = sqlCmd.ExecuteScalar()

Return Retorno

Catch ex As Exception
MsgBox(ex.Message())
End Try

End Function

End Class
KILLER 04/05/2010 13:23:01
#340889
onde vc esta chamando a funcao eu nao vi
PARREIRA 04/05/2010 13:32:04
#340892
Estou chamando no tmp_internet,mas ja achei o erro,o return está no local errado,tem que ficar abaixo do try catch.
Tópico encerrado , respostas não são mais permitidas