所以我把我的代碼是這樣的:試圖解釋ASP.Net錯誤
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<%
using System.Data.SqlClient
public Static Main {
connection = new SqlConnection();
connection.ConnectionString = "Data Source=localhost:8080;Initial Catalog=dbo.Table1;";
connection.Open();
dataadapter = new SqlDataAdapter("select * from customers", connection);
}
%>
<h2>This is a test for a database connection</h2> <%Response.Write(dataadapter) %>
</asp:Content>
而且我得到了以下錯誤消息:
Source Error:
Line 6: using System.Web.UI.WebControls;
Line 7:
Line 8: public partial class _Default : System.Web.UI.Page
Line 9: {
Line 10: protected void Page_Load(object sender, EventArgs e)
我能擺脫它的唯一的事情就是我可能會錯誤地輸入一些代碼?這個錯誤對我來說很不透明。
我的語法有什麼問題嗎?
是否有錯誤消息?或者它真的只是說'源錯誤'? – David 2011-12-13 20:01:33