欢迎光临
我们一直在努力

[ASP.NET]对Oracle数据库创建表/判断数据表是否已存在-ASP教程,数据库相关

建站超值云服务器,限时71元/月

对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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » [ASP.NET]对Oracle数据库创建表/判断数据表是否已存在-ASP教程,数据库相关
分享到: 更多 (0)