版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 注册会计师审计中会计估计审计的风险评估程序
- 2026四川成都市新津区外国语实验小学校面向社会招聘教师18人备考题库含答案详解(黄金题型)
- 2026广西柳州融安县长安镇卫生院乡村医生招聘2人备考题库附答案详解(研优卷)
- 房地产企业账务处理实操案例(含收入核算)
- 2206江西鹰潭市邮政分公司现面向社会招聘合同用工备考题库附参考答案详解(精练)
- 2026扬州平山堂茶业发展有限公司招聘茶饮店劳务派遣人员2人备考题库及答案详解【典优】
- 2026山东济南市第一人民医院招聘卫生高级人才和博士(控制总量)18人备考题库及答案详解【历年真题】
- 2026山东济南市第五人民医院招聘卫生高级人才和博士(控制总量)8人备考题库及答案详解【典优】
- 2026新疆喀什昆仑建设有限公司招聘3人备考题库及参考答案详解(综合卷)
- 2026广东深圳高级中学集团招聘23人备考题库及答案详解【易错题】
- 企业车间绩效考核制度
- 医疗服务价格项目立项指南解读辅导2026
- 中兴新云逻辑测试题
- 全过程造价咨询服务的质量、进度、保密等保证措施
- 2025年四川省眉山市中考数学试卷
- 企业管理 华为会议接待全流程手册SOP
- 2026年心理咨询师考试题库及答案
- 高中物理课堂中实验教学的数字化改造课题报告教学研究课题报告
- 2026年忻州职业技术学院单招职业适应性考试题库参考答案详解
- 社保业务考试大纲及复习题库
- DB J33 T 1271-2022 建筑施工高处作业吊篮安全技术规程
评论
0/150
提交评论