2
我在SQL Server 2008 Management Studio的本地主機上創建了一個新數據庫(AC_2012
)。Visual Studio 2010找不到在SQL Server Management Studio中創建的數據庫
我試圖通過連接字符串連接到Visual Studio 2010 Premium中的web.config
。它不會拿起它。
<configuration>
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<connectionStrings>
<add name="AC_2012"
connectionString="server=.\SQLEXPRESS;database=AC_2012; integrated security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
而這裏的如何,我試圖調用連接字符串..是還沒有完成..
public static void storedProcedure(string[] paramName, string[] paramValue, string sproc)
{
SqlConnection conn = null;
SqlDataReader reader = null;
try
{
string connStr = ConfigurationManager.ConnectionStrings["AC_2012"].ConnectionString;
conn = new SqlConnection(connStr);
reader = new SqlDataReader();
DataTable dt = new DataTable();
conn.Open();
SqlCommand cmd = new SqlCommand(sproc, conn);
for (int x = 0; x < paramName.Count(); x++)
{
cmd.Parameters.Add(new SqlParameter(paramName[x], paramValue[x]));
}
reader = cmd.ExecuteReader();
while (reader.Read())
{
}
}
catch (Exception e)
...
爲什麼你想讓你的評論顯示爲被引用的文本?你在做什麼使得更難以一眼看出什麼是代碼,什麼不是。此外,[請不要包括你好/謝謝/等](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts) – 2012-03-13 01:43:44