簡體   English   中英

使用System.Data.Odbc的編譯錯誤;

[英]Compilation error with using System.Data.Odbc;

我只是第一次嘗試使用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();
%>

我不確定“使用”行有什么問題。 任何幫助將非常感激。

<% ... %>塊的內容是放在Execute方法內部的語句
您不能將using指令放在方法中。

相反,您需要使用ASP.Net <%@ Import %>指令

<%@ Import Namespace="System.Data.Odbc" %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM