Imports System.Data.SqlClient
Imports System.Data Public Class BogartAutoCodeDataBase Private Conn As SqlClient.SqlConnection = SqlConnect
Sub New()
'Conn = New BogartAutoCodeConnection
End Sub ' 保存的错误!
Private _StrError As String = ""
Friend ReadOnly Property StrError() As String
Get
Return _StrError
End Get
End Property #Region "执行命令,返回影响的行数"
'执行但行命令
Function ExecuteNonQuery(ByVal SqlCommandText As String, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As Integer
Return ExecuteNonQuery(SqlCommandText, Nothing, SqlCommandType)
End Function '执行但行命令
Function ExecuteNonQuery(ByVal SqlCommandText As String, ByVal SqlParameters As ArrayList, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As Integer
Dim ret As Integer = -
Try
Dim SqlComm As SqlCommand = CreateSqlComm(SqlCommandText, SqlParameters, SqlCommandType)
If SqlComm Is Nothing Then
Return
End If
ret = DataAccess.ExectueCmd(SqlComm)
Return ret
Catch ex As System.Exception
ret = -
_StrError = ex.Message & vbCrLf & ex.StackTrace
End Try
Return ret
End Function
#End Region #Region "执行命令,返回影响的行数"
'执行但行命令
Function ExecuteBool(ByVal SqlCommandText As String, ByVal SqlParameters As ArrayList, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As Boolean
Dim ret As Integer =
ret = ExecuteNonQuery(SqlCommandText, SqlParameters, SqlCommandType)
If ret >= Then
Return True
Else
Return False
End If
End Function '执行但行命令
Function ExecuteBool(ByVal SqlCommandText As String, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As Boolean
Return ExecuteNonQuery(SqlCommandText, Nothing, SqlCommandType) >= And Len(Me.StrError)
End Function #End Region #Region "执行命令,返回单值"
'执行但行命令
Function ExecuteScalar(ByVal SqlCommandText As String, ByVal SqlParameters As ArrayList, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As Object Dim SqlComm As SqlCommand = CreateSqlComm(SqlCommandText, SqlParameters, SqlCommandType)
If SqlComm Is Nothing Then
Return Nothing
End If
Try
Return SqlComm.ExecuteScalar
Catch ex As Exception
_StrError = ex.Message & vbCrLf & ex.StackTrace
End Try End Function
'执行但行命令
Function ExecuteScalar(ByVal SqlCommandText As String, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As Object
Return ExecuteScalar(SqlCommandText, Nothing, SqlCommandType)
End Function
#End Region #Region "加载数据集合"
Function LoadDateSet(ByVal SqlCommandText As String, ByVal SqlParameters As ArrayList, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As DataSet
Dim SQLCMD As SqlClient.SqlCommand = CreateSqlComm(SqlCommandText, SqlParameters, SqlCommandType)
Return DataAccess.ExectueSQL(SQLCMD)
End Function
Function LoadDateSet(ByVal SqlCommandText As String, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As DataSet
Return LoadDateSet(SqlCommandText, Nothing, SqlCommandType)
End Function
#End Region #Region "创建SqlCommand对象"
'创建命令对象
Function CreateSqlComm(ByVal SqlCommandText As String, ByVal SqlParameters As ArrayList, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As SqlCommand
Dim comm As New SqlCommand If Not OpenConn(Conn) Then
Me._StrError = "Sorry, system not found DataServer or DataServer Closed!"
Return Nothing
End If
With comm
.Connection = Conn
.CommandType = SqlCommandType
.CommandText = SqlCommandText
.CommandTimeout =
End With
AddParameters(comm, SqlParameters)
Return comm
End Function
Function CreateSqlComm(ByVal SqlCommandText As String, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As SqlCommand
Return CreateSqlComm(SqlCommandText, Nothing, SqlCommandType)
End Function
Function CreateSqlComm()
Return CreateSqlComm("", Nothing, CommandType.Text)
End Function #End Region #Region "处理参数" '这里处理参数
Sub AddParameters(ByVal SqlComm As SqlCommand, ByVal SqlParameters As ArrayList)
If Not SqlParameters Is Nothing AndAlso SqlParameters.Count > Then
For Each Sqlp As SqlParameter In SqlParameters
SqlComm.Parameters.Add(Sqlp)
Next
End If
End Sub #End Region #Region "创建Datareader对象"
'创建Datareader对象
Function CreateSqlDataReader(ByVal SqlCommandText As String, ByVal SqlParameters As ArrayList, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As SqlDataReader
Dim comm As SqlCommand = Me.CreateSqlComm(SqlCommandText, SqlParameters, SqlCommandType)
If comm Is Nothing Then
Return Nothing
End If
Return comm.ExecuteReader(CommandBehavior.CloseConnection)
End Function
Function CreateSqlDataReader(ByVal SqlCommandText As String, Optional ByVal SqlCommandType As CommandType = CommandType.Text) As SqlDataReader
Return Me.CreateSqlDataReader(SqlCommandText, Nothing, SqlCommandType)
End Function
#End Region End Class

Bogart BogartAutoCode.vb的更多相关文章

  1. Bogart BogartPublic.vb

    Imports System.Data.SqlClient Imports System.Data #Region "IBogartToolbar,請勿隨便更改" Interfac ...

  2. Bogart SysPwd.vb

    Module syspwd Public Const STR_MASK = "MyFunction" '加密用字串 '預定義密碼長度 Public GintCheckPwd As ...

  3. Bogart gSub.vb

    '--------------Job No 0900408 -------------- '--DIM PART ONE ONLINE Update Order Qty '''主要新加過程名 Refr ...

  4. Bogart gData.vb

    Imports System Imports System.Data Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports S ...

  5. Bogart gFunction.vb

    Module gFunction '其它不是常用的方法及函數 #Region " 將指定的數據格式轉換為英文格式" Public Function EnglishFormat(By ...

  6. Bogart gGrid.vb

    Namespace BogartMis.Cls Public Class gGrid '設定表格控的列標題的別名 '說明:strItem字符串的格式為"01,02,03,04,05" ...

  7. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  8. VB.NET设置控件和窗体的显示级别

    前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...

  9. 用VB脚本批到导入字段到PowerDesigner

    在PowerDesigner使用脚本批量导入excel中记录的表结构信息,由于需要通过powerdesigner逆向工程创建一些sybase IQ的表,由于是接口数据,只有excel表,手动导入太耗时 ...

随机推荐

  1. opencv-python教程学习系列3-视频操作

    前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍视频的获取和保存,坚持学习,共同进步. 系列教程参照OpenCV-Python中文教程: 系统环境 ...

  2. [LeetCode&Python] Problem 496. Next Greater Element I

    You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...

  3. [LeetCode&Python] Problem 617. Merge Two Binary Trees

    Given two binary trees and imagine that when you put one of them to cover the other, some nodes of t ...

  4. CodeForces - 778C: Peterson Polyglot (启发式合并trie树)

    Peterson loves to learn new languages, but his favorite hobby is making new ones. Language is a set ...

  5. Windows 10中更新Anaconda和第三方包

    =============================== 作为专业的Python开发者,Anaconda包肯定很熟悉 下面总结一下Anaconda的升级和维护 步骤一: 打开cmd,切换到Ana ...

  6. Python 实现画一个小猪佩奇

    ===================================== 看到 佩奇的广告片刷红,为了迎接猪年,咱们也来用Python  画板实现一个效果吧 from turtle import* ...

  7. 《DSP using MATLAB》Problem 3.5

    定义为: 如果序列绝对可和,其DTFT就存在.

  8. Linux内核中的机制学习总结

    一.驱动中的poll机制 1.简介:select()和poll()系统调用的本质一样,前者在 BSD UNIX 中引入的,后者在 System V 中引入的. 应用程序使用 select() 或 po ...

  9. lsof-查看进程句柄

    root@root:~# lsof COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME systemd root cwd DIR , / sy ...

  10. hasura-graphql 集成 pipelinedb 1.0.0

    pipelinedb 1.0.0 已经是一个标准的pg 扩展了,同时以前的语法也有变动,但是集成进hasura-graphql 更方便了 使用docker-compose 运行 环境准备 docker ...