0
<%@ WebHandler Language="C#" Class="SITEIMPORT" %>
using System;
using System.Web;
using MySql.Data;
using MySql.Data.MySqlClient;
/// <summary>
/// IMPORTS DATA FROM MYSQL TO OUR WEBSITE
/// </summary>
public class SITEIMPORT : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string connStr = "server=mysql2.DOMAINREMOVED.com;user=MYUSERNAME;database=DBNAME;port=3306;password=MYPASSWORD;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
context.Response.Write("Connecting to MySQL...");
context.Response.Write("efef");
conn.Open();
context.Response.Write("done");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
conn.Close();
Console.WriteLine("Done.");
}
public bool IsReusable {
get {
return false;
}
}
}
這將輸出響應:無法連接到MySQL
連接到MySQL ... efef
這並不是說登錄失敗,服務器沒有找到,服務器阻塞請求,類似的東西。沒有錯誤。任何人都知道爲什麼「完成」不打印出來?
你能否確認該方法正在完成執行並且不會打開連接? – 2011-03-29 23:23:15
@巴巴克,我會怎麼做,對不起,我是一個noob。 – 2011-03-29 23:24:14
用調試器運行代碼並執行。 – 2011-03-29 23:25:47