Bogart BogartAutoCode.vb
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的更多相关文章
- Bogart BogartPublic.vb
Imports System.Data.SqlClient Imports System.Data #Region "IBogartToolbar,請勿隨便更改" Interfac ...
- Bogart SysPwd.vb
Module syspwd Public Const STR_MASK = "MyFunction" '加密用字串 '預定義密碼長度 Public GintCheckPwd As ...
- Bogart gSub.vb
'--------------Job No 0900408 -------------- '--DIM PART ONE ONLINE Update Order Qty '''主要新加過程名 Refr ...
- Bogart gData.vb
Imports System Imports System.Data Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports S ...
- Bogart gFunction.vb
Module gFunction '其它不是常用的方法及函數 #Region " 將指定的數據格式轉換為英文格式" Public Function EnglishFormat(By ...
- Bogart gGrid.vb
Namespace BogartMis.Cls Public Class gGrid '設定表格控的列標題的別名 '說明:strItem字符串的格式為"01,02,03,04,05" ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- VB.NET设置控件和窗体的显示级别
前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...
- 用VB脚本批到导入字段到PowerDesigner
在PowerDesigner使用脚本批量导入excel中记录的表结构信息,由于需要通过powerdesigner逆向工程创建一些sybase IQ的表,由于是接口数据,只有excel表,手动导入太耗时 ...
随机推荐
- 【opencv基础】detectmultiscale函数详解
前言 简单的人脸检测程序可以直接基于opencv的函数库进行实现,本文介绍一下detectMultiScale函数. 函数简介 opencv2人脸检测使用的是detectMultiScale函数,可以 ...
- 【linux基础】查看硬盘位置信息
nvidia@tegra-ubuntu:/media/nvidia/Elements/data$
- 【opencv基础】linux系统opencv以及opencv_contrib的安装与使用
前言 本文主要介绍如何在linux系统安装使用opencv. 具体步骤可参考opencv官网here. 步骤 编译源码之前需要安装相关依赖库: 1.下载源码: 2.解压源码: 3.配置cmake: 注 ...
- 堆优化的dij【模板】
#include<iostream> #include<cstdio> #include<cstring> #include<queue> using ...
- 【正则表达式】java应用正则表达式
一:简单应用 /** * * ' * & * ' * & * & * ' * ' * ' * sources=sdcg'hde&xyz'dfa&&ad' ...
- LG3812 【模板】线性基
题意 给定n个整数(数字可能重复),求在这些数中选取任意个,使得他们的异或和最大. \(1≤n≤50,0≤S_i≤2^{50}\) 分析 模板题. 推荐一篇好博客 现在我来证明一下线性基的性质. 性质 ...
- CentOS升级Python2.6到Python2.7并安装pip
原文:http://ruter.sundaystart.net/2015/12/03/Update-python/ 貌似CentOS 6.X系统默认安装的Python都是2.6版本的?平时使用以及很多 ...
- git的使用方法学习
1.git常用命令: git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致.同时,将当前的工作区内容保存到Git栈中. git stash p ...
- TFTP error: 'Only absolute filenames allowed' (2)
hisilicon # tftp 0x82000000 u-boot-hi3518ev200.bin Hisilicon ETH net controler MAC: ----- eth0 : phy ...
- python之 列表常用方法
更多列表的使用方法和API,请参考Python文档:http://docs.python.org/2/library/functions.html append:用于在列表末尾追加新对象: # app ...