有人可以幫助我將這個腳本轉換爲C#我仍然是一個初學者,並在C#中學習。該腳本使用OpenCurrentDatabase打開(並保持打開)一個Access .mdb文件,我必須使用此方法和代碼,因爲它是,但轉換爲C#,任何幫助將非常感激。將VBScript轉換爲C#
我用記事本編輯CS文件並CSC.EXE編譯它(我沒有任何其他C#工具)。
dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
dim filePath
filePath = fso.GetParentFolderName(WScript.ScriptFullName)
filePath = filePath & "\test.mdb"
'WScript.Echo filePath
If (fso.FileExists(filePath)) Then
dim appAccess
set appAccess = createObject("Access.Application")
appAccess.visible = true
appAccess.UserControl = true 'To leave the application open after the script completes you need to set the UserControl property to true.
appAccess.OpenCurrentDatabase filePath, True, "mypassword"
Else
WScript.Echo "File doesn’t exist"
End If
你需要打開數據庫,以便用戶可以手動訪問它,或者你要插入/查詢以編程方式(使用C#)? – Bassie