我使用的是包含mySQL數據庫的godaddy虛擬主機服務;連接超時問題
我正在使用visual studio 2010開發我的web應用程序使用asp.net和c#。
我配置爲直接訪問(遠程訪問),但一半我得到這個異常時的數據庫:
"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."
我試圖找出如果我的代碼錯誤或原因是在服務器,這是我的代碼:
我在web.config中的連接字符串
<add name="GameDataServer"
connectionString="Server=<server host>; Port=3306; Database=<database name>; Uid=<uid>; Pwd=<password>; pooling=false;"
providerName="MySql.Data.MySqlClient;Connection Timeout=10; default command timeout=800;" />
我拉數據代碼:
MySqlConnection myConnection;
MySqlDataAdapter myDataAdapter;
string strSQL;
myConnection = new MySqlConnection(this.connectionString);
strSQL = "SELECT * FROM table1";
myDataAdapter = new MySqlDataAdapter(strSQL, myConnection);
DataSet myDataSet = new DataSet();
try
{
myDataAdapter.Fill(myDataSet, "table1");
}
任何幫助表示讚賞
感謝
多倫
你應該使用連接池。 pooling = true –
table1有多大?嘗試「SELECT TOP(1)* FROM table1」,看看你是否仍然有問題。 – christofr
您是否關閉並處置所有涉及的對象,如連接? –