版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026ibm 前端 面试题及答案
- 2026java的高级面试题及答案
- 2026linux简答面试题及答案
- 2026年涂料环保检测技工试题及答案
- 小学五年级科学“铁生锈的条件”专题探究知识清单
- 2026年竞业限制管理专员试题及答案
- 高中二年级物理 闭合电路欧姆定律知识清单
- 2026年教师资格证教育知识及能力试题及答案
- 2026年基金从业资格(证券投资基金)试题及答案
- 初中道德与法治七年级上册“友谊的层次与边界”教学设计
- 湖北省武汉市江汉区北湖小学2025年数学三下期末质量检测模拟试题含解析
- 2026年注册安全工程师考试《安全管理》冲刺押题试卷(含解析)
- 2026-2030中国碳化硅(SiC)半导体器件市场发展现状及未来供需平衡预测报告
- (2026年)手术安全核查与风险评估课件
- 2025北京市朝阳区太阳宫乡社区工作者招聘考试真题及答案
- 2026年国家电投招聘笔试参考题库含答案解析
- 防范银狐木马病毒与补贴诈骗信息课件
- 2026版中央安全生产考核巡查明查暗访应知应会
- 肥西反邪教协会工作制度
- 六化建设培训
- TSG08-2026《特种设备使用管理规则》全面解读课件
评论
0/150
提交评论