您的位置:首页 > 编程语言 > VB

vb.net调用存储过程简单示例

2011-09-18 00:19 417 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: