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. Connecting to SQL !!!

Connecting to SQL !!!

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelpquestion
4 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.
  • M Offline
    M Offline
    mrkeivan
    wrote on last edited by
    #1

    Hey guys, whats up ? I want to connect to SQL in ASP.NET In my main form I have this code: I have added a SQLDatasource for my connection string ! MyConn.ConnectionString = SqlDataSource1.ConnectionString; MyConn.Open(); MyCmd.CommandText = "SELECT UserName from UserT where UserName = " + UserName_tb.Text; string CheckName = (string)MyCmd.ExecuteScalar(); in this line I get this error ! ExecuteScalar: Connection property has not been initialized.

    M 1 Reply Last reply
    0
    • M mrkeivan

      Hey guys, whats up ? I want to connect to SQL in ASP.NET In my main form I have this code: I have added a SQLDatasource for my connection string ! MyConn.ConnectionString = SqlDataSource1.ConnectionString; MyConn.Open(); MyCmd.CommandText = "SELECT UserName from UserT where UserName = " + UserName_tb.Text; string CheckName = (string)MyCmd.ExecuteScalar(); in this line I get this error ! ExecuteScalar: Connection property has not been initialized.

      M Offline
      M Offline
      mani_iips
      wrote on last edited by
      #2

      The error is self explanatory. You havent set the connection property for "MyCmd" i.e. sqlCommand. Not very sure about VB syntax, but you need to do something like. "MyCmd.Connection = MyConn " It shud solve problem.

      M 1 Reply Last reply
      0
      • M mani_iips

        The error is self explanatory. You havent set the connection property for "MyCmd" i.e. sqlCommand. Not very sure about VB syntax, but you need to do something like. "MyCmd.Connection = MyConn " It shud solve problem.

        M Offline
        M Offline
        mrkeivan
        wrote on last edited by
        #3

        Thanx dude ! you ve been very helpful ! Mr.K

        M 1 Reply Last reply
        0
        • M mrkeivan

          Thanx dude ! you ve been very helpful ! Mr.K

          M Offline
          M Offline
          mani_iips
          wrote on last edited by
          #4

          Most welcome Mr K. Since am quite new to scores here.. wud really appreciate if you grade my reply and articles. :)

          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