1.資料查詢
//mytans是連線資料庫的事物物件
//資料庫連線
mytrans=create transaction
mytrans.dbms = "odbc"
mytrans.autocommit = false //關閉自動提交資料庫更新,另外mytrans.autocommit=true//開啟自動提交資料庫更新
mytrans.dbparm = "connectstring='dsn=quality'"
connect using mytrans;
//以上一般在應用程式的open事件
//以下在視窗輸入產品型號調出編號的**:
string serialno0
string value
if sle_1.text="" then
messagebox("information","沒提供資料")
return
else
value=sle_1.text
end if
mytrans.autocommit=true//開啟自動提交資料庫更新
select serialno into :serialno0 from product_base where partno=:value using mytrans;
if mytrans.sqlcode=-1 then
messagebox("information","sql語句出錯")
elseif mytrans.sqlcode=100 then
messagebox("information","未找到資料")
else
st_3.text=serialno0
end if
mytrans.autocommit=false//關閉自動提交資料庫更新
////關閉連線,一般在應用程式關閉closed事件
disconnect using mytrans;
2.插入資料
string serialno0
string value
if sle_1.text="" then
messagebox("information","沒提供資料")
return
else
value=sle_1.text
end if
//查詢是否已有資料
select serialno into :serialno0 from product_base where partno=:value using mytrans;
if mytrans.sqlcode=-1 then
messagebox("information","sql語句出錯")
elseif mytrans.sqlcode=0 then
messagebox("information","已有此資料")
return
else
insert into product_base(partno) values (:value) using mytrans;
commit using mytrans;
messagebox("infomation","已插入資料")
end if
3.刪除資料
string serialno0
string value
integer rtn
if sle_1.text="" then
messagebox("information","沒提供資料")
return
else
value=sle_1.text
end if
//查詢是否已有資料
select serialno into :serialno0 from product_base where partno=:value using mytrans;
if mytrans.sqlcode=-1 then
messagebox("information","sql語句出錯")
elseif mytrans.sqlcode=100 then
messagebox("information","未查找到資料")
return
else
rtn=messagebox("確認資訊","確定刪除嗎?",question!,yesno!,1)
if rtn=1 then
delete from product_base where partno=:value using mytrans;
commit using mytrans;
messagebox("infomation","已刪除資料")
else
return
end if
end if
4.更改資料
string serialno0
string value1,value2
integer rtn
if sle_1.text="" or sle_2.text=""then
messagebox("information","沒提供資料")
return
else
value1=sle_1.text
value2=sle_2.text
end if
//查詢需要更改的資料是否存在
select serialno into :serialno0 from product_base where partno=:value1 using mytrans;
if mytrans.sqlcode=-1 then
messagebox("information","sql語句出錯")
elseif mytrans.sqlcode=100 then
messagebox("information","未查找到資料")
return
else
//查詢更改後的資料是否重複,主要對關鍵字不能重複時
select serialno into :serialno0 from product_base where partno=:value2 using mytrans;
if mytrans.sqlcode=-1 then
messagebox("information","sql語句出錯")
elseif mytrans.sqlcode=0 then
messagebox("information","修改後資料已存在,不能重複")
return
else
rtn=messagebox("確認資訊","確定更改嗎?",question!,yesno!,1)
if rtn=1 then
update product_base set partno=:value2 where partno=:value1 using mytrans;
commit using mytrans;
messagebox("infomation","已更改資料")
else
return
end if
end if
end if
初識嵌入式 嵌入式開發概述
1 什麼是嵌入式技術 1 嵌入式軟體與非嵌入式軟體的區別?答 嵌入式軟體是結合作業系統之上做的開發 非嵌入式軟體是做的裸機開發。裸機 沒有作業系統 2 嵌入式開發與微控制器開發的區別?答 區別 是否有作業系統。拓展 答 優點 解決了軟體的移植性 解決了開發人員的能力的劃分問題。提供了豐富的網路協議 ...
如何學習嵌入式 嵌入式如何入門?
學習嵌入式,該學習什麼基本的知識呢?嵌入式如何入門?其次,應該對作業系統有所了解,這對你對硬體和軟體的理解,絕對有很大的幫助。應該把系統的管理理解一下,比如程序 執行緒,系統如何來分配資源的,系統如何來管理硬體的,當然,不是看書就能把這些理解透,如果不是一時能理解,沒關係,多看看,結合以後的專案經驗...
非嵌入式與嵌入式的區別
非嵌入式是通過軟體控制硬體,軟硬體之間直接聯絡來實現要求。但是一旦硬體發生改變軟體也要改變,為了降低這種偶合度過高的問題,出現了嵌入式。嵌入式在軟體和硬體之間新增了作業系統,軟體通過控制作業系統進而控制硬體,硬體發生改變並不會導致軟體也發生改變,這為軟體開發人員節約了很多時間,並且嵌入式能在已有的硬...