Private Function validateClient( ByVal guid As String ) As Integer Dim result As Integer = 0 Try ' 读client Dim client As SqlDataReader Dim connStr As String = ConfigurationManager.ConnectionStrings( " wz " ).ConnectionString Dim conn As New SqlConnection(connStr) Dim cmd As New SqlCommand( " redlim_client_getdetailbyguid " , conn) cmd.CommandType = CommandType.StoredProcedure With cmd.Parameters .Add( New SqlClient.SqlParameter( " @clientguid " , guid)) End With conn.Open() client = cmd.ExecuteReader If Not client Is Nothing AndAlso client.HasRows Then client.Read() result = Integer .Parse(client( " redlimClientState " )) ' 获取client的状态 client.Close() Else ' 无client,新建client client.Close() cmd = New SqlCommand( " redlim_client_create " , conn) cmd.CommandType = CommandType.StoredProcedure With cmd.Parameters .Add( New SqlClient.SqlParameter( " @clientguid " , guid)) End With cmd.ExecuteNonQuery() End If Catch ex As Exception End Try Return result End Function