我有一個嵌套的gridview和它的可編輯。雖然它使用訪問作爲測試目的的數據源,但我想用mysql數據源來部署它。我意識到有什麼不對。我的Gridview必須在搜索被點擊時顯示。 這是我原來的訪問數據源代碼:綁定子Gridview
//This procedure prepares the query to bind the child GridView
private AccessDataSource ChildDataSource(string strCustometId, string strSort)
{
string strQRY = "";
AccessDataSource dsTemp = new AccessDataSource();
dsTemp.DataFile = "App_Data/BV.mdb";
strQRY = "Query statement";
dsTemp.SelectCommand = strQRY;
return dsTemp;
}
我改變以適應MySQL用戶。
private SqlDataSource ChildDataSource(string strCustometId, string strSort)
{
string strQRY = "";
SqlDataSource dsTemp = new SqlDataSource();
dsTemp.ID = "dsTemp";
string sCon= WebConfigurationManager.ConnectionStrings["bv"].ConnectionString;
dsTemp.ConnectionString = sCon;
strQRY = "Query stament here";
dsTemp.SelectCommand = strQRY;
return dsTemp;
}
這是來自web.config的我的連接字符串。
<connectionStrings>
<add name="bv" connectionString="server=localhost;database=cms;Connect Timeout=30;Persist Security Info=False;User id = root;password=xxxxx" providerName="MySql.Data.MySqlClient"/>
第二個代碼給出了錯誤,並表示用戶登錄失敗「根」。我的連接字符串和數據源代碼有問題。我沒有經驗,請在這方面需要幫助。
您需要向我們顯示您的連接字符串。你可以檢查[ConnectionStrings.com](http://connectionstrings.com)的例子,有一堆。 – jadarnel27 2013-04-08 12:48:09
感謝您的答覆。我編輯了代碼。檢查了connectionString.com網站,並使用了他們的指導方針。 – 2013-04-08 12:54:50