1
我發現了一個非常好的示例,說明如何從經典ASP文件中獲取數據並將其吐出到新的MS Access文件中。我的一個問題是我需要將列的「必需」屬性設置爲false,以便如果該列中沒有數據存在,它不會崩潰。谷歌搜索讓我得到不同的語法結果,它似乎並沒有工作。如果有人可以幫助我設置這個例子的財產,我會很感激。將VBScript中的「Required = False」設置爲MS Access文件
dim provider : provider = "microsoft.jet.oledb.4.0"
dim db : db = "c:\Documents and Settings\*****\Desktop\foodb.mdb"
dim ds : ds = "provider=" & provider & "; data source=" & db
dim catalog:set catalog=createobject("adox.catalog")
catalog.create ds 'create db file
'const for column types
const adInteger=3 'integer
const adVarChar=202 'variable character
dim new_table:set new_table=createobject("adox.table")
new_table.Name="customer"
new_table.columns.append "id", adInteger
new_table.columns.append "surname", adVarChar
new_table.keys.append "pk_cust_id", 1, "id" 'primary key
catalog.Tables.Append new_table 'append table to DB
'release resources
set new_table=nothing
set catalog=nothing
'By this point, DB is now created
'populate table
dim conn: set conn=createobject("adodb.connection") 'create connection
conn.open ds 'open connection
sql="insert into customer (id, surname) values (5, 'smith')"
conn.Execute sql
'close connection and reclaim resources
conn.close
set conn=nothing
我沒有時間更改代碼並對其進行測試,但請在此處查看:http://allenbrowne.com/func-adox.html如果需要,請在頁面上搜索單詞「必需」 – HK1