我正在设置一个自定义选项卡,用户可以在其中查看和编辑数据.我需要建立一个受信任的SQL连接,并在网格视图中显示数据.
我应该构建一个控制台或Web应用程序吗?
我在下面提供了我的.aspx和aspx.cs文件.
我在运行它时收到以下错误消息:
"错误:确保此代码文件中定义的类与'inherits'属性匹配,并且它扩展了正确的基类(例如Page或UserControl)".
这是我的Default.aspx代码:
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的Default.aspx.cs代码:
///<summary>
///Demonstrates how to work with SqlConnection objects
///</summary>
class SqlConnectionDemo
{
static void Main()
{
// 1. Instantiate the connection
SqlConnectionconn = newSqlConnection("Data Source=TestDB;Initial Catalog=Impresario;Integrated Security=SSPI");
SqlDataReaderrdr = null;
try
{
// 2. Open the connection
conn.Open();
// 3. Pass the connection to a command object
SqlCommandcmd = newSqlCommand("select * from LT_WEB_DONATIONS_EXTRA_INFO_TEMP", conn);
//
// 4. Use …Run Code Online (Sandbox Code Playgroud)