Use SqlExec to create and delete a table in the specified database called
"new_table".
<%
' declare variables
dim cnString, strSQL
' set variables
cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
server.mappath("./db.mdb") & ";"
strSQL = ""
strSQL = strSQL & "CREATE TABLE new_table" & vbCrLf
strSQL = strSQL & "(" & vbCrLf
strSQL = strSQL & "ID Int Identity(1, 1)," & vbCrLf
strSQL = strSQL & "field1 VarChar(255) Identity(1, 1) " & vbCrLf
strSQL = strSQL & ")" & vbCrLf
' sqlexec statement to create table
SqlExec cnString, strSQL
' sqlexec statement to delete the table that
' was just created.
SqlExec cnString, "DROP TABLE new_table"
%>
<%
Private Sub SqlExec(byVal ConnString, byVal SQL)
Dim objCn, bErr1, bErr2, strErrDesc
On Error Resume Next
Set objCn = Server.CreateObject("ADODB.Connection")
objCn.Open ConnString
If Err Then
bErr1 = True
Else
objCn.Execute SQL
If Err Then
bErr2 = True
strErrDesc = Err.Description
End If
End If
objCn.Close
Set objCn = Nothing
On Error GoTo 0
If bErr1 then
Err.Raise 5109, "SqlExec Statement", "Bad connection " & _
"string. Database cannot be accessed."
ElseIf bErr2 then
Err.Raise 5109, "SqlExec Statement", strErrDesc
End If
End Sub
%>