ASP判断表是否存在
发布网友
发布时间:2022-04-14 20:26
我来回答
共3个回答
热心网友
时间:2022-04-14 21:55
on error resume next '屏蔽出错提示
rs.open "table1",conn1 '打开你要的表table1
if not err.number=0 then '如果表不存在
Err.Clear '清除该错误 Response.write "表不存在" '提示表不存在elseResponse.write "表存在" '提示表存在
end if
热心网友
时间:2022-04-14 23:13
Function GetTableName(DBpath)
dim rs
dim Conn
set conn = server.CreateObject("ADODB.Connection")
conn.Open "Dbq=" & DBpath & ";Defaultdir=;Driver={Microsoft Access Driver (*.Mdb)};Driverid=25;Fil=Ms Access;Implicitcommitsync=Yes;Maxbuffersize=512;Maxscanrows=8;Pagetimeout=5; Safetransactions=0;Threads=3;Usercommitsync=Yes;", "Administrator", "admin"
set rs = Conn.OpenSchema(20) do while not rs.eof
if rs("table_type") ="TABLE" then
GetTablename =GetTableName & "," & rs("TABLE_NAME")
end if
rs.moveNext
loop
rs.close
conn.Close
set rs = nothing
End Functionresponse.write GetTableName("C:\yours.mdb")
if instr(GetTableName("C:\yours.mdb"),"表名")<>0 Then
response.write "表存在"
else sql="create table yourtable (y_id integer identity(1,1) primary key,y_name varchar(50) not null default '张三')"conn.ExeCute(SQL)
response.write "新建表完成"
end if