Error in objConexao = New SqlConnection(connString); ??
-
Hi, All the time is showing me error at line: objConexao = New SqlConnection(connString); which says that I forgot the semicolon(;), but as you can see I did not forget it! See the whole routine bellow inside a .aspx page: <%@ Page Language="C#" Debug="true"%> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> public void Page_Load(Object Sender, EventArgs EA) { String connString,strSQL; SqlConnection objConexao; SqlCommand objCommand; SqlDataReader objDataReader; connString = "Server=Localhost; Database=Northwind; Uid=SqlService; Password=xx;"; objConexao = New SqlConnection(connString); objConexao.Open(); strSQL = "SELECT * FROM Products"; objCommand = New SqlCommand(strSQL, objConexao); objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection); While(objDataReader.Read = True) { lblSaida.Text += objDataReader["ProductName"] + " - " + objDataReader["UnitPrice"] + "<br>"; } objDataReader.Close(); objConexao.Close(); objDataReader = Nothing; objCommand = Nothing; objConexao = Nothing; } So, how can I solve it? ------------- Thanks, ========================= Vilmar Brazão de Oliveira
-
Hi, All the time is showing me error at line: objConexao = New SqlConnection(connString); which says that I forgot the semicolon(;), but as you can see I did not forget it! See the whole routine bellow inside a .aspx page: <%@ Page Language="C#" Debug="true"%> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> public void Page_Load(Object Sender, EventArgs EA) { String connString,strSQL; SqlConnection objConexao; SqlCommand objCommand; SqlDataReader objDataReader; connString = "Server=Localhost; Database=Northwind; Uid=SqlService; Password=xx;"; objConexao = New SqlConnection(connString); objConexao.Open(); strSQL = "SELECT * FROM Products"; objCommand = New SqlCommand(strSQL, objConexao); objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection); While(objDataReader.Read = True) { lblSaida.Text += objDataReader["ProductName"] + " - " + objDataReader["UnitPrice"] + "<br>"; } objDataReader.Close(); objConexao.Close(); objDataReader = Nothing; objCommand = Nothing; objConexao = Nothing; } So, how can I solve it? ------------- Thanks, ========================= Vilmar Brazão de Oliveira
-