我是一名学习ASP.NET的PHP开发人员,似乎只需要做一些简单的事情就像连接到数据库一样。
当我执行以下操作时。
<%@ Page Language="C#"%>
<%
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
//Connect to database
SqlConnection connection = new SqlConnection("Server=MYSQL5003.Smarterasp.net;Database=yyy;Uid=zzz;Pwd=xxx;");
//Determine the action we're performing
switch(Request.QueryString["action"]){
case "unsubscribe":
Response.Write(Request.QueryString["email"]);
break;
case "export":
Response.Write(Request.QueryString["action"]);
break;
default:
//Default action
break;
}
%>
由于某种原因,我收到语法错误。
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1003: Syntax error, '(' expected
Source Error:
Compilation Error
Line 1: <%@ Page Language="C#"%>
Line 2: <%
Line 3: using System.Data.SqlClient;
Line 4: using MySql.Data.MySqlClient;
Line 5: //Connect to database
我不应该放置&#34;使用&#34;另一个文件中的陈述?
答案 0 :(得分:1)
在aspx页面上引入内联命名空间时,必须使用@Import。
<%@ Import Namespace="System.Data.SqlClient" %>