版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、本文格式為word版,下載可任意編輯vb讀寫ini文件及訪問mysql數(shù)據(jù)庫的示例 loadsettings()和savesettings()是讀寫ini文件的例子,留意要先把ini文件名賦值給inifile這個(gè)變量。getsqlval()函數(shù)從指定的mysql服務(wù)器的指定表中通過指定的sql抓取一個(gè)數(shù)值。 vb讀寫ini文件,及訪問mysql數(shù)據(jù)庫的示例。 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的字符串轉(zhuǎn)成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這個(gè)變量。getsqlval()函數(shù)從指定的mysql服務(wù)器的指定表中通過指定的sql抓取一個(gè)數(shù)值。 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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年標(biāo)準(zhǔn)砌體工程分包合同樣本一
- 美食springboot課程設(shè)計(jì)
- 專題01基礎(chǔ)知識(shí)綜合(原卷版)
- 用戶畫像課程設(shè)計(jì)
- 自然課程設(shè)計(jì)營(yíng)銷推廣
- 換熱網(wǎng)絡(luò)課程設(shè)計(jì)
- 理論課程設(shè)計(jì)需要考慮
- 湖南省株洲市2024-2025學(xué)年高三上學(xué)期期末考試政治試題(解析版)
- 直播器材培訓(xùn)課程設(shè)計(jì)
- 汽修行業(yè)修理工技能提升總結(jié)
- 2024年機(jī)動(dòng)車檢測(cè)站質(zhì)量手冊(cè)程序文件記錄表格合集(根據(jù)補(bǔ)充要求編制)
- 2023-2024學(xué)年上海市普陀區(qū)三年級(jí)(上)期末數(shù)學(xué)試卷
- 中國(guó)特色大國(guó)外交和推動(dòng)構(gòu)建人類命運(yùn)共同體
- 《風(fēng)電場(chǎng)項(xiàng)目經(jīng)濟(jì)評(píng)價(jià)規(guī)范》(NB-T 31085-2016)
- 2022年sppb簡(jiǎn)易體能狀況量表
- 各類傳染病個(gè)案調(diào)查表集
- 全口義齒PPT課件
- 室內(nèi)裝飾裝修工程施工組織設(shè)計(jì)方案(完整版)
- 消防系統(tǒng)檢測(cè)方案(完整版)
- 關(guān)于童話故事的題目
- 工程竣工驗(yàn)收備案申請(qǐng)表1
評(píng)論
0/150
提交評(píng)論