Üye Kayıt Üye Giriş

ADOX Örneği 1


 ADOX Örneği 1


' -------------------------------------------- '
' Coder: Tuğrul TOPUZ a.k.a. threedot '
' E-Mail: threedot@hotmail.it '
' Date: 05-01-2007 '
' Time: 16:26 '
' Version: v0.1 '
' Filename: ADOX_SAMPLE1.VBS '
' Interpreter: Windows Scripting Host 5.6 '
' -------------------------------------------- '

'object(s) definition
dim oADOx,oFSO
'object(s) initialize
set oADOx=CreateObject("ADOX.Catalog")
set oFSO=CreateObject("Scripting.FileSystemObject")

'database settings
const sFileName="sample_db.mdb"

'subroutines & functions
sub DBStatics(oTables)
dim sResult
dim oTable,oColumn
sResult=_
"~ : tablo"&vbCrLf&_
"+ : field"&vbCrLf&vbCrLf
for each oTable in oTables
sResult=sResult&"~"&oTable.Name&vbCrLf
for each oColumn in oTable.Columns
sResult=sResult&" +"&oColumn.Name&vbCrLf&_
" - type :"&oColumn.Type&vbCrLf&_
" - size :"&oColumn.DefinedSize&vbCrLf
next
next
WScript.Echo(sResult)
sResult=empty
set oTable=nothing
set oColumn=nothing
end sub

'gavuştur
dim sConnStr,sSQL
sConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&sFileName&";"
if oFSO.FileExists(sFileName) then oFSO.DeleteFile(sFileName)
call oADOx.Create(sConnStr)
with oADOx.ActiveConnection
sSQL="CREATE TABLE t_table1(id INT,isim VARCHAR(30),soyisim VARCHAR(30),gorev VARCHAR(30),durum VARCHAR(30))"
call .Execute(sSQL)
sSQL="INSERT INTO t_table1(id,isim,soyisim,gorev,durum) VALUES(1,'Tuğrul','TOPUZ','Bilgisayar Yazılım/Donanım','Orta Şeker')"
call .Execute(sSQL)
sSQL="INSERT INTO t_table1(id,isim,soyisim,gorev,durum) VALUES(2,'Muhammed','TEKİNKUŞ','Bilgisayar Yazılım/Donanım','Çaylak')"
call .Execute(sSQL)
end with
call DBStatics(oADOx.Tables)
call oADOx.ActiveConnection.Close()
'object(s) terminating
set oADOx=nothing
set oFSO=nothing

Bilgisayar Dershanesi Ders Sahibi;
Bilgisayar Dershanesi

Yorumlar

Yorum Yapabilmek İçin Üye Girişi Yapmanız Gerekmektedir.

ETİKETLER