文件名称:
VB通过配置文件System.ini连接数据库
开发工具:
文件大小: 3kb
下载次数: 0
上传时间: 2012-03-09
详细说明: Public conn As New ADODB.Connection Public nowconnectstring As String Public operatetype As Integer Public Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String, ByVal lpRetunedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long Public Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpAdd As String, ByVal lpFileName As String) As Boolean 'Public pzhm As Variant Public server As String Public loginname As String Public database As String Public pass As String Public path As String Private mSystemData As Object '帐套连接信息对象(帐套名,当前用户等) '=================================================================='定义公用变量 '在工程中新建一模块,并将以下代码加入到该的模块中(即module1.bas) Public tmpDataGrid As DataGrid '用与确定要实现滚动的DataGrid控件 Public tmpDataGridRowNum As Long '有多少行数据 Public Const GWL_WNDPROC = (-4) Public Const WM_COMMAND = &H111; Public Const WM_MBUTTONDOWN = &H207; Public Const WM_MBUTTONUP = &H208; Public Const WM_MOUSEWHEEL = &H20A; Public Oldwinproc As Long Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Public Property Get SystemProfile() As Object If mSystemProfile Is Nothing Then Set mSystemProfile = GLData.SystemProfile End If Set SystemProfile = mSystemProfile End Property Public Property Set SystemProfile(ByVal NewVal As Object) Set mSystemProfile = NewVal Set GLData.SystemProfile = NewVal End Property Public Property Get SystemData() As Object If mSystemData Is Nothing Then Set mSystemData = CreateObject("EBCBase.ClientBase").SystemData End If Set SystemData = mSystemData End Property '====================================== '数据库链接 Public Function connectstring() As String If Len(GetFromINI("数据库信息", "数据库", App.path + "\system.ini")) = 0 Then MsgBox "没有连接数据库", vbOKOnly, "警告" Else connectstring = GetFromINI("数据库信息", "数据库", App.path + "\system.ini") server = GetFromINI("数据库信息", "server", App.path + "\system.ini") loginname = GetFromINI("数据库信息", "loginname", App.path + "\system.ini") database = GetFromINI("数据库信息", "database", App.path + "\system.ini") pass = GetFromINI("数据库信息", "pass", App.path + "\system.ini ") path = GetFromINI("数据库信息", "path", App.path + "\system.ini ") End If End Function Public Function GetFromINI(AppName As String, KeyName As String, filename As String) As String Dim RetStr As String RetStr = String(255, Chr(0)) GetFromINI = Left(RetStr, GetPrivateProfileString(AppName, ByVal KeyName, "", RetStr, Len(RetStr), filename)) End Function Public Sub data_open() nowconnectstring = connectstring If conn.state <> 1 Then conn.CursorLocation = adUseClient conn.Open nowconnectstring End If End Sub 调用data_open方法 ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.