2008-12-03 135 views

回答

4

這樣的事情,很明顯你的連接代碼會有所不同(更好):

SqlConnection conn = null; 
conn = new SqlConnection("yourConnectionString"); 
conn.Open(); 
string strSQLCommand = "CREATE VIEW vw_YourView AS SELECT YOurColumn FROM YourTable"; 
SqlCommand command = new SqlCommand(strSQLCommand, conn); 
string returnvalue = (string)command.ExecuteScalar(); 
conn.Close(); 
3

您可以使用下面的代碼編寫查詢視圖:

query = " Create View [Viewname] Select ...."; 

執行查詢。

相關問題