


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、本文格式为word版,下载可任意编辑vb读写ini文件及访问mysql数据库的示例 loadsettings()和savesettings()是读写ini文件的例子,留意要先把ini文件名赋值给inifile这个变量。getsqlval()函数从指定的mysql服务器的指定表中通过指定的sql抓取一个数值。 vb读写ini文件,及访问mysql数据库的示例。 attribute vb_name = module3option explicitpublic declare function getprivateprofilestring lib kernel32 alias getprivate
2、profilestringa (byval lpapplicationname as string, byval lpkeyname as any, byval lpdefault as string, byval lpreturnedstring as string, byval nsize as long, byval lpfilename as string) as longpublic declare function getprivateprofileint lib kernel32 alias getprivateprofileinta (byval lpapplicationna
3、me as string, byval lpkeyname as string, byval ndefault as long, byval lpfilename as string) as longpublic declare function writeprivateprofilestring lib kernel32 alias writeprivateprofilestringa (byval lpapplicationname as string, byval lpkeyname as any, byval lpstring as any, byval lpfilename as s
4、tring) as longtype appsettingl16netenabled(3) as booleanl16nethost(3) as stringl16netport(3) as integerchabointerval as integerend typetype mysql_settinghost as stringport as integerusername as stringpassword as stringdbname as stringsql as stringenabled as booleanend typepublic inifile as stringpub
5、lic appset as appsettingpublic mysqlset(3) as mysql_settingpublic function inireadstring(byval appname as string, byval keyname as string, byval default as string, byval filename as string) as stringdim retstr as stringretstr = string(10000, 0)inireadstring = left(retstr, getprivateprofilestring(app
6、name, byval keyname, default, retstr, len(retstr), filename)end functionsub loadsettings()dim i as integerfor i = 1 to ubound(appset.l16nethost) + 1with appset.l16nethost(i - 1) = inireadstring(main, l16nethost i, 192.168.0.100, inifile).l16netport(i - 1) = getprivateprofileint(main, l16netport i, 1
7、881, inifile).l16netenabled(i - 1) = cbool(inireadstring(main, l16netenabled i, 0, inifile) 将“true、“false的字符串转成boolean值end withnext iappset.chabointerval = getprivateprofileint(main, chabointerval, 10, inifile)for i = 1 to ubound(mysqlset) + 1with mysqlset(i - 1).host = inireadstring(mysql, host i,
8、192.168.0.100, inifile).port = getprivateprofileint(mysql, port i, 3306, inifile).username = inireadstring(mysql, username i, root, inifile).dbname = inireadstring(mysql, dbname i, , inifile).password = inireadstring(mysql, password i, , inifile).sql = inireadstring(mysql, sql i, , inifile).enabled
9、= cbool(inireadstring(mysql, enabled i, false, inifile)end withnext iend subsub savesettings()dim i as integerdim v as integerfor i = 1 to ubound(appset.l16nethost) + 1with appset loadsettings()和savesettings()是读写ini文件的例子,留意要先把ini文件名赋值给inifile这个变量。getsqlval()函数从指定的mysql服务器的指定表中通过指定的sql抓取一个数值。 writepr
10、ivateprofilestring main, l16nethost i, .l16nethost(i - 1), inifile writeprivateprofilestring main, l16netport i, cstr(.l16netport(i - 1), inifilewriteprivateprofilestring main, l16netenabled i, cstr(.l16netenabled(i - 1), inifile 写入的是“true、“falseend withnext iwriteprivateprofilestring main, chaboint
11、erval, cstr(appset.chabointerval), inifilefor i = 1 to ubound(mysqlset) + 1with mysqlset(i - 1)writeprivateprofilestring mysql, host i, .host, inifilewriteprivateprofilestring mysql, port i, cstr(.port), inifilewriteprivateprofilestring mysql, username i, .username, inifilewriteprivateprofilestring
12、mysql, password i, .password, inifilewriteprivateprofilestring mysql, dbname i, .dbname, inifilewriteprivateprofilestring mysql, sql i, .sql, inifilewriteprivateprofilestring mysql, enabled i, cstr(.enabled), inifileend withnext iend subfunction getsqlval(idx as integer) as integerdim con as adodb.c
13、onnectiondim rds as adodb.recordsetdim strconnect as stringstrconnect = driver=mysql odbc 5.1 driver; _uid= mysqlset(idx).username ;pwd= mysqlset(idx).password ; _server= mysqlset(idx).host ;port= mysqlset(idx).port ; _database= mysqlset(idx).dbname ;set con = new adodb.connectionuse a client-side c
14、ursorcon.cursorlocation = aduseclienton error goto err_1con.open strconnectset rds = new adodb.recordsetthe only type of curor that you can use witha client side cursor location is adopenstatic.rds.cursortype = adopenstaticrds.cursorlocation = aduseclientthis guarantees that a record that is being e
15、ditedcan be saved.rds.locktype = adlockpessimistica sql statement indicating which data to get from the database.rds.source = mysqlset(idx).sqlrds.activeconnection = conopen the record set. opening the recordset willcause the movecomplete event for the recordset to fire.rds.openif the pointer is at the end of the recordset ofat the before
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 弹性体多孔材料的制备及其隔热、电磁屏蔽性能研究
- 基于分布鲁棒优化的软间隔支持向量机问题研究
- 营销理论培训课件
- 设备备品备件管理制度
- 脑出血诊断与治疗
- 银行新员工清廉培训
- 药剂科专业知识
- 育儿保健知识讲座
- 药厂年终总结模板
- 解剖学及生理学试题及答案
- 2024-2025学年第二学期天域全国名校协作体高三3月联考 地理试卷(含答案)
- 修理木桥施工合同范本
- 学校2025年每日两小时体育活动方案-阳光体育活力四溢
- 新教科版一年级科学下册第一单元第6课《哪个流动得快》课件
- 屋面种植土垂直施工方案
- 2025年新人教PEP版英语三年级下册全册课时练习
- 《爱耳日课件》课件
- 2024年安徽中医药高等专科学校高职单招职业适应性测试历年参考题库含答案解析
- GB/T 45107-2024表土剥离及其再利用技术要求
- 2025年保密工作计划(3篇)
- 2025年中国移动通信集团甘肃限公司校园招聘290人高频重点提升(共500题)附带答案详解
评论
0/150
提交评论