对oracle数据库创建表:
dim myconnectionstring as string
dim myconnection as oledbconnection
dim mycommand as oledbcommand
dim mycreatesql as string
myconnectionstring = "provider=oraoledb.oracle.1;user id=[user id];data source=[data source];extended properties=;persist security info=true;password=[password]"
myconnection = new oledbconnection(myconnectionstring)
mycreatesql = "create table (abc varchar2(10))"
mycommand = new oledbcommand(mycreatesql)
mycommand.connection = myconnection
myconnection.open()
mycommand.executenonquery()
mycommand.connection.close()
判断数据表是否已存在:
databasename –表名
private function sqlexistdatabase(byval databasename as string) as boolean
dim orcconndb as oracleconnection
dim strselect as string
dim odaexistdatabase as oracledataadapter
dim dsexistdatabase as new dataset
orcconndb = new oracleconnection
orcconndb.connectionstring = "data source=[data source];" _
& "persist security info=false;" _
& "user id=[]user id;password=[password];"
orcconndb.open()
strselect = "select count(*) from user_tables where table_name=" & replaceen(databasename) & ""
odaexistdatabase = new oracledataadapter(strselect, orcconndb)
odaexistdatabase.fill(dsexistdatabase)
if dsexistdatabase.tables(0).rows(0)(0) = 0 then
orcconndb.close()
return false
else
orcconndb.close()
return true
end if
end function
小写英字转换成大写英字
enstring — 字符串
private function replaceen(byval enstring as string) as string
dim i as integer
for i = asc("a") to asc("z")
enstring = enstring.replace(cchar(chrw(i)), cchar(chrw(i – 32)))
next
return enstring
end function
