VB6,把数据库配置文件写到INI文件

qcxht 2012-08-21 09:18:24
一个INI文件,是数据库连接的配置

怎么样实现 读写INI文件,来连接数据库配置
...全文
116 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
大东哥哥的爹 2012-08-26
  • 打赏
  • 举报
回复

‘还要加这个。
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
大东哥哥的爹 2012-08-26
  • 打赏
  • 举报
回复
'这是读的。

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32

'Public strFtpTargetPath As String = GetINI("FTP", "strFtpTargetPath", "", Pth)
Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String '读ini
Dim Str As String = ""
Str = LSet(Str, 256)
GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)
Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)
End Function
’这是写的。

Public Function WriteIniString(ByVal section As String, ByVal keystring As String, ByVal value1 As String) As Object

WritePrivateProfileString(section, keystring, value1, VB6.GetPath & "\HSMacro.ini")
WriteIniString = value1
End Function
waynexjw828 2012-08-25
  • 打赏
  • 举报
回复
楼上回答,好像不是在点上
hzybc 2012-08-23
  • 打赏
  • 举报
回复
'写入INI文件
FileOpen(1, "C:\y.ini", OpenMode.Output)
PrintLine(1, "我是一个兵")
PrintLine(1, "来自老百姓")
。。。。
FileClose(1)

'读INI文件
Dim xC as string
FileOpen(1, "C:\y.ini", OpenMode.Input)
xc=lineinput(1)
。。。。
FileClose(1)

'还可以用 IO.StreamReader 和 IO.StreamWriter



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

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧