L
Lasse Edsvik
Hello
Why i get:
Compiler Error Message: CS1519: Invalid token '(' in class, struct, or interface member declaration
Line 10: Conn.Open();
with this code:
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="c#" runat="server">
SqlConnection Conn = new SqlConnection(
ConfigurationSettings.AppSettings("ConnectionString"));
const string SQL = "SELECT * FROM Customers";
SqlCommand Cmd = new SqlCommand(SQL, Conn);
Conn.Open();
nw.DataSource = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
nw.DataBind();
</script>
<html>
<body>
<asp:datagrid id="nw" runat="server" />
</body>
</html>
web.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="User ID=myuid;Password=mypass;Initial Catalog=Northwind;Data
Source=localhost"/>
</appSettings>
<system.web></system.web>
</configuration>
Why i get:
Compiler Error Message: CS1519: Invalid token '(' in class, struct, or interface member declaration
Line 10: Conn.Open();
with this code:
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="c#" runat="server">
SqlConnection Conn = new SqlConnection(
ConfigurationSettings.AppSettings("ConnectionString"));
const string SQL = "SELECT * FROM Customers";
SqlCommand Cmd = new SqlCommand(SQL, Conn);
Conn.Open();
nw.DataSource = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
nw.DataBind();
</script>
<html>
<body>
<asp:datagrid id="nw" runat="server" />
</body>
</html>
web.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="User ID=myuid;Password=mypass;Initial Catalog=Northwind;Data
Source=localhost"/>
</appSettings>
<system.web></system.web>
</configuration>