随笔-97  评论-105  文章-46  trackbacks-1

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

    Private Function validateClient(ByVal guid As StringAs 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
posted on 2011-09-18 00:19 Konimeter 阅读(14) 评论(0) 编辑 收藏
我的公司:
ShangXun.Net一站式网络服务
昵称:Konimeter
园龄:6年5个月
粉丝:1
关注:1
<2011年9月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

搜索

 
 

常用链接

随笔分类(96)

文章分类(15)

.NET

最新评论

推荐排行榜