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:unassigned local variable 'value'?

error:unassigned local variable 'value'?

Scheduled Pinned Locked Moved ASP.NET
helpsharepointtutorialquestion
2 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.
  • S Offline
    S Offline
    srinivassam
    wrote on last edited by
    #1

    hi all , i wrote one webmethod in webservice , from that webmethod i am returning string but i am getting unassigned local variable value , how to solve this problem? [WebMethod] public string GetCountryList() { string connectionString = ConfigurationManager.ConnectionStrings["iphoneConnection"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); SqlCommand comm = new SqlCommand(); comm.CommandType = CommandType.StoredProcedure; comm.CommandText = "sp_name"; comm.Connection = connection; connection.Open(); SqlDataReader objdatareader; objdatareader=comm.ExecuteReader(); string Value; while (objdatareader.Read()) { Value = objdatareader.ToString(); } objdatareader.Close(); connection.Close(); return Value; } Thanks& Regards RamaDevi.

    samrama

    B 1 Reply Last reply
    0
    • S srinivassam

      hi all , i wrote one webmethod in webservice , from that webmethod i am returning string but i am getting unassigned local variable value , how to solve this problem? [WebMethod] public string GetCountryList() { string connectionString = ConfigurationManager.ConnectionStrings["iphoneConnection"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); SqlCommand comm = new SqlCommand(); comm.CommandType = CommandType.StoredProcedure; comm.CommandText = "sp_name"; comm.Connection = connection; connection.Open(); SqlDataReader objdatareader; objdatareader=comm.ExecuteReader(); string Value; while (objdatareader.Read()) { Value = objdatareader.ToString(); } objdatareader.Close(); connection.Close(); return Value; } Thanks& Regards RamaDevi.

      samrama

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      I think there is some problem in data from DB.Give some default value to you string.Then if data is coming properly then you will get the result else you'll get default value.

      Cheers!! Brij

      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