0
我在.net中很新,我希望這個問題不會聽起來很愚蠢。如何在.net c#中的webmethod中執行以下sql腳本到數據庫?如何在.net c#web應用程序中的web服務器中執行sql腳本?
在Web.config中我有代碼連接到數據庫,下面的代碼:
<connectionStrings>
<add name="TestConnectionString" connectionString="Data Source=TXT-TEST-SQL-02;Initial Catalog=Test;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
我怎麼能下test.asmx.cs做 - 的webmethod從數據庫中運行下面的腳本來檢索來自表格的數據?
[WebMethod]
public string testSearch(int id)
{
return result;
}
SELECT name
FROM Customer
WHERE customer_id = id
@Bala:這是給我的錯誤是說ConfigurationManager中 ''名稱' 不能在當前的背景下存在 – 2011-04-06 23:35:36
@Jin勇確保你有所有必需的'使用'。 – 2011-04-06 23:37:09
用於參數化查詢。 – spender 2011-04-06 23:41:43