我只是第一次尝试使用aspx而且我得到了一个 CS1003:语法错误,'('预期 第3行出错。
这是我的代码:
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<%
using System.Data.Odbc;
// Connection
string connectionString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=db;User=user;password=pass";
OdbcConnection conn = new OdbcConnection(connectionString);
conn.open();
%>
我不确定“使用”行有什么问题。任何帮助将非常感激。
答案 0 :(得分:3)
<% ... %>
块的内容是语句,它们放在Execute
方法内。
您不能在方法中放置using
指令。
相反,您需要使用ASP.Net <%@ Import %>
directive:
<%@ Import Namespace="System.Data.Odbc" %>