我正在使用Windows應用程序。在這裏,我需要在運行時在MS Access 2007中創建存儲的查詢(即在按鈕單擊時)選擇,插入,更新,刪除,如何根據參數調用表單中的查詢?如何在運行時使用C#在MS Access中創建存儲查詢
cmmd.CommandText = "CREATE TABLE tblCustomers ([CustomerID] AUTOINCREMENT PRIMARY KEY, CustomerName Text(50), [CategoryID] Long REFERENCES tblCategories (CategoryID), [IsActive] YesNo, [ModifiedBy] Long REFERENCES tblUsers (UserID), [ModifiedDate] Date)";
cmmd.ExecuteNonQuery();
//Above Create table tblCustomers executed successfully,
cmmd.CommandText = @"CREATE PROCEDURE prAddCustmer (CustName Text(50), CatID Long, Inact No, ModBY Long, ModDate date) AS INSERT INTO tblCustomers (CustomerName , CategoryID, Inactive, ModifiedBy, ModifiedDate) VALUES(CustName, [CatID], [Inac], [ModBy], [ModDate]);";
cmmd.ExecuteNonQuery();
//But got error in Create Procedure prAddCustomers, Please find error in the Stored query and suggest the correct answer
//Syntax error in PARAMETER clause.
你的問題不明確。你想調用一個已經存在於你的數據庫中的查詢,或者你想在你的數據庫中創建一個查詢嗎? – Steve
我需要先創建存儲的查詢,然後我應該從其他實例調用它。首先我需要創建數據庫及其對象,如表,首先存儲查詢。現在我創建了數據庫和表格,並保留了查詢。 – Sanjeev4evr