因此,这是我关于在C#使用(联线集合)的尝试的样本代码。 现在,我认为这给我留下了一个错误,因为这不是一种方法。 然而,是否有办法解决这一问题?
<% @Page Language="C#" %>
<% @Import Namespace="System.Data.Odbc" %>
<% @Import Namespace="System.Web.Configuration" %>
<script language="C#" runat="server">
string conString = WebConfigurationManager.ConnectionStrings["cheese"].ConnectionString;
using (OdbcConnection con = new OdbcConnection(conString)) {
con.Open();
using (OdbcCommand com = new OdbcCommand("SELECT pies FROM ducks WHERE isapie = nope", con)) {
com.Parameters.AddWithValue("@var", paramWord);
using (OdbcDataReader reader = com.ExecuteReader()) {
while (reader.Read()) {
Response.Write(reader.GetString(0));
}
}
}
con.Close();
}
</script>
现在,错误的行文是:
Line 8: using (OdbcConnection con = new OdbcConnection(conString)) {
上述错误是:
Compiler Error Message: CS1519: Invalid token using in class, struct, or interface member declaration
I am trying to keep my code minimalistic, easy to edit, etc. and so I d like to avoid having unnecessary classes, methods, etc. simply for the sake of having them.