【配置】:用户名,密码,IP 端口,数据库名称
1:将配置文件放入 DataBase.ini 文档[uid]=sa[pwd]=dwz10110511[srn]=127.0.0.1,1754[sysdb]=yygl
2:建立标准模块 Module1
Public SRN As String
Public uID As String
Public PWD As String
Public SysDB As String
'系统的 main() 主函数 读取配置文件
Sub Main()
Dim Intext As String Open (App.Path & "\DataBase.ini") For Input As #1
Line Input #1, Intext
uID = Mid(Intext, 7, Len(Trim(Intext)) - 6)
Line Input #1, Intext
PWD = Mid(Intext, 7, Len(Trim(Intext)) - 6)
Line Input #1, Intext
SRN = Mid(Intext, 7, Len(Trim(Intext)) - 6)
Line Input #1, Intext
SysDB = Mid(Intext, 9, Len(Trim(Intext)) - 8)
Close #1
登录窗口.Show vbModal
End Sub
【select】:
Dim conn As New ADODB.Connection'建立连接对象
Dim rs As New ADODB.Recordset'记录集对象
conn.Open "provider=SQLOLEDB;Data Source=" & SRN & ";User ID=" & uID & ";Password=" & PWD & ";Initial catalog=" & SysDB
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.Open "select * from 病区管理", conn, , , adCmdText
Set msf1.DataSource = rs
msf1.Refresh
'关闭连接 释放内存
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
【insert,delete,update】:
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.Open "provider=SQLOLEDB;Data Source=" & SRN & ";User ID=" & uID & ";Password=" & PWD & ";Initial catalog=" & SysDB
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
conn.Execute "insert,delete,update的语句"
'关闭连接 释放内存
conn.Close
Set rs = Nothing
Set conn = Nothing
1:将配置文件放入 DataBase.ini 文档[uid]=sa[pwd]=dwz10110511[srn]=127.0.0.1,1754[sysdb]=yygl
2:建立标准模块 Module1
Public SRN As String
Public uID As String
Public PWD As String
Public SysDB As String
'系统的 main() 主函数 读取配置文件
Sub Main()
Dim Intext As String Open (App.Path & "\DataBase.ini") For Input As #1
Line Input #1, Intext
uID = Mid(Intext, 7, Len(Trim(Intext)) - 6)
Line Input #1, Intext
PWD = Mid(Intext, 7, Len(Trim(Intext)) - 6)
Line Input #1, Intext
SRN = Mid(Intext, 7, Len(Trim(Intext)) - 6)
Line Input #1, Intext
SysDB = Mid(Intext, 9, Len(Trim(Intext)) - 8)
Close #1
登录窗口.Show vbModal
End Sub
【select】:
Dim conn As New ADODB.Connection'建立连接对象
Dim rs As New ADODB.Recordset'记录集对象
conn.Open "provider=SQLOLEDB;Data Source=" & SRN & ";User ID=" & uID & ";Password=" & PWD & ";Initial catalog=" & SysDB
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.Open "select * from 病区管理", conn, , , adCmdText
Set msf1.DataSource = rs
msf1.Refresh
'关闭连接 释放内存
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
【insert,delete,update】:
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.Open "provider=SQLOLEDB;Data Source=" & SRN & ";User ID=" & uID & ";Password=" & PWD & ";Initial catalog=" & SysDB
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
conn.Execute "insert,delete,update的语句"
'关闭连接 释放内存
conn.Close
Set rs = Nothing
Set conn = Nothing