I have a vbscript that trying to create the table in MS Access DB, but i want to make it like if the table is exists, then it will direct proceed to enter data without need of creating the table.
What can i do to check the existing of the table is created or not?
My code as below, it will not proceed to insert data if the table is already exists.
'Constants
'Const adOpenStatic = 3
Const adOpenDynamic = 2
Const adLockOptimistic = 3
Const adCmdTable = &H0002
Set objConn = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
'Connect Primary DB
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & "C:\AIS_Workfolder\Reference\DB\" & "AIS_DataDB.mdb"
'Open Connection
objConn.open connStr
'Create table
objConn.Execute "CREATE TABLE " & "test_table" & "(" & _
"[ID] COUNTER ," & _
"[Field1] TEXT(255) ," & _
"[Field2] TEXT(255) ," & _
"[Field3] TEXT(255) ," & _
objRecordSet.Open "test_table", objConn, adOpenDynamic, adLockOptimistic, adCmdTable
objRecordSet.AddNew
objRecordSet("Field1").value = "testing123"
objRecordSet("Field2").value = "testing123"
objRecordSet("Field3").value = "testing123"