Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error in objConexao = New SqlConnection(connString); ??

Error in objConexao = New SqlConnection(connString); ??

Scheduled Pinned Locked Moved ASP.NET
questioncsharpdatabasesysadmindebugging
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vilmarbr
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • V vilmarbr

      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

      M Offline
      M Offline
      Marcie Jones
      wrote on last edited by
      #2

      Hi Vilmar, "New" on that line should be lower-case: "new". C# is case-sensitive. The error message is not particularly helpful in this case. Hope that helps! Marcie CP Blog[^]

      V 1 Reply Last reply
      0
      • M Marcie Jones

        Hi Vilmar, "New" on that line should be lower-case: "new". C# is case-sensitive. The error message is not particularly helpful in this case. Hope that helps! Marcie CP Blog[^]

        V Offline
        V Offline
        vilmarbr
        wrote on last edited by
        #3

        Thank you guy, I had forgot that C# as Java, JavaScript, C, C++ are all case SENSITIVE! Regards, ========================= Vilmar Brazão de Oliveira

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups