1
我想連接到ASPNETDB但它使一個錯誤說:「用戶登錄失敗」 這是web配置連接字符串:如何直接連接到ASPNETDB數據庫
<add name="UserProfiles" connectionString="Data Source=KIA;Initial Catalog=aspnetdb;Integrated Security=True;"
providerName="System.Data.SqlClient" />
,這是我的代碼:
SqlConnection connection = new SqlConnection();
SqlCommand ComNewCheckSum = new SqlCommand();
connection.ConnectionString = ConfigurationManager.ConnectionStrings["UserProfiles"].ConnectionString;
connection.Open();
ComNewCheckSum.Connection = connection;
ComNewCheckSum.CommandText = String.Format("select UserID from aspnet_Users where UserName = {0}", _UserName);
return Convert.ToInt32(ComNewCheckSum.ExecuteScalar());
我怎麼能通過錯誤?謝謝
兩兩件事 - 1)你嘗試登錄到SQL Server(手動)與這些憑據?它工作嗎? 2)爲什麼要針對成員資格模式手動執行SQL?您需要的邏輯沒有被Membership API覆蓋嗎? 'Membership.GetUser()'不夠? – RPM1984 2010-10-19 08:31:45