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. PR

    3.1音频轨道与播放 单声道音轨: 立体声音轨:立体声音频文件 3.2 音频过渡 需要先把第一段视频的结尾与第二段视频的开头切除,然后在使用恒定功率. 3.3  调音台的简单使用 调节音频: 显示声音 ...

  2. centos yum出现no module named yum

    运行yum出现如下错误 There was a problem importing one of the Python modules required to run yum. The error l ...

  3. dockerk个人学习(0)

    接下来几篇记录学习docker和ks的部署搭建环境和应用部署等

  4. 感悟:Java新手一点想法

    在2年前写的博客,写的那么幼稚,工作了,工作经验多重要啊,有3年的开发经验,工资8000-12000 没接触Java框架之前,以为这些东西多神秘,多了不起,多高大上,其实也就那样 最重要的搞懂交互的流 ...

  5. MySQL--增加或修改列注释

    ##=============================================## ## 在创建表的时候为字段添加注释 ## CREATE TABLE TB003 ( ID INT P ...

  6. /etc/grub.conf

    http://leejia.blog.51cto.com/4356849/788902 grub.conf是grub的主配置文件,通过这个配置文件,grub才能找到kernel,系统才能正常启动. # ...

  7. 基于windows IIS的C语言CGI WEB服务器环境搭建

    网页编程对我来说特别亲切,因为我就是从html.ASP.PHP一步步接触编程的.自己的编程爱好也是从那里一点一点被满足.不过离开大学之后很久没有碰过WEB了,最近看到嵌入式中的涉及到的web服务器,了 ...

  8. C语言面试题5

    C语言面试宝典 第一部分:基本概念及其它问答题 1.关键字static的作用是什么? 这个简单的问题很少有人能回答完全.在C语言中,关键字static有三个明显的作用: 1). 在函数体,一个被声明为 ...

  9. FastAdmin selectPage 前端传递查询条件

    ★夕狱-东莞 2018/2/2 16:19:33 selectpage 怎么在前端传递查询条件,看了下源码,好像有个custom,怎么用来的,比如我要下拉的时候,只显示id=1的数据 Karson-深 ...

  10. handler之责任链模式

    https://www.cnblogs.com/java-my-life/archive/2012/05/28/2516865.html