---------------------------
---------------------------
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.)
---------------------------
OK
---------------------------
,實際上意味着什麼呢?
我認爲,「事情花了太長時間,所以我放棄了。」
我不明白爲什麼會出現超時,因爲我將超時設置爲4分鐘,並且此錯誤在不到30秒的時間內彈出。
爲什麼這個確切的代碼在過去的一週工作,現在它只是失敗了每一次?
我試過設置cmd.CommandTimeout = 240
這是一個很長的時間來等待調試時,和同樣的問題。數據庫中沒有任何更新。我不明白髮生了什麼變化。
try
{
// Insert into database
sqlconnection = new SqlConnection(@"Data Source=s1-removed-om;Initial Catalog=D-removed-t;Persist Security Info=True;User ID=D-removed-;Password=97-removed3-45;");
sqlconnection.Open();
cmd = new SqlCommand();
cmd.Connection = sqlconnection;
int count = 0;
foreach (var item in files)
{
cmd.CommandText = @"insert into Images (Name, Credits) values ('" + item.Value + "', '" + credits + "')";
cmd.ExecuteNonQuery();
count++;
}
doneUpdatingDB = true;
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
doneUpdatingDB = false;
}
您可以看看:http://stackoverflow.com/questions/3270199/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ – Jivan