sto cercando di connettermi ad un db sql server:
codice:<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <script language=C# runat="server"> String ConnStringPop = ConfigurationManager.ConnectionStrings["conn"].ConnectionString; SqlConnection objConnectPop = new SqlConnection(ConnStringPop); objConnectPop.Open ; string sqlPop = "SELECT * FROM tb_prodotti"; SqlCommand cmdPop = new SqlCommand(sqlPop, objConnectPop); SqlDataReader drPop = cmdPop.ExecuteReader(); if (drPop.HasRows) { if(drPop.Read()){ pop = true; lblMsg.Text = drPop["testo"].ToString(); } } else { pop = false; } drPop.Close(); objConnectPop.Close(); </script>l'errore è:codice:<?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="conn" connectionString="Server=xx.xx.xxx.xx; User Id=miodb; Password=miapwd; Database=miodb; Persist Security Info=True" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <customErrors mode="Off"/> <compilation debug="true"/> </system.web> <appSettings> </appSettings> </configuration>
Compiler Error Message: CS1519: Invalid token ';' in class, struct, or interface member declaration
Line 7: objConnectPop.Open;
:master:

Rispondi quotando