⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module1.bas

📁 这个是我们软件工程的课程设计成果
💻 BAS
字号:
Attribute VB_Name = "Module1"

Public UserName As String


Public Function ExecuteSQL(ByVal SQL As String, MsgString As String) As ADODB.Recordset

Dim cnn As ADODB.Connection

Dim rst  As ADODB.Recordset

Dim sTokens() As String

On Error GoTo ExecuteSQL_Error

sTokens = Split(SQL)

Set cnn = New ADODB.Connection

cnn.Open ConnectString

If InStr("INSERT,DELETE,UPDATE", UCase$(sTokens(0))) Then
cnn.Execute SQL
MsgString = sTokens(0) & "query successful"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
Set ExecuteSQL = rst
MsgString = "查询到" & rst.RecordCount & "条记录"
End If

ExecuteSQL_Exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function

ExecuteSQL_Error:
MsgString = "查询错误:" & Err.Description
Resume ExecuteSQL_Exit

End Function

Public Function ConnectString() As String
'ConnectString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=abc;Data Source=D3B537BD27F445A"
ConnectString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Train;Data Source=CHENYIDAN"
End Function

Public Function Testtxt(txt As String) As Boolean
If Trim(txt) = "" Then
  Testtxt = False
Else
  Testtxt = True
End If
End Function


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -