HI我正在嘗試將數據插入Azure上託管的數據庫。我得到一個豁免錯誤。我在本地數據庫上測試了下面的代碼,它工作正常。 Azure需要一些額外的代碼嗎?未將數據插入Azure SQL數據庫
protected void Submit_Click(object sender, System.EventArgs e)
{
SqlConnection conn;
SqlCommand comm;
string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
conn = new SqlConnection(connectionString);
comm = new SqlCommand("INSERT INTO Site (SiteName, SiteEmail) VALUES (@SiteName, @SiteEmail)", conn);
comm.Parameters.Add("@SiteName", System.Data.SqlDbType.Text);
comm.Parameters["@SiteName"].Value = "Whatever Time, Place";
comm.Parameters.Add("@SiteEmail", System.Data.SqlDbType.Text);
comm.Parameters["@SiteEmail"].Value = "[email protected]";
try
{
conn.Open();
comm.ExecuteNonQuery();
label1.Text = "It worked";
}
catch
{
label1.Text = "Error submitting the form!";
}
finally
{
conn.Close();
}
}
你有什麼異常? – Teppic 2014-09-06 01:49:25