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. Database & SysAdmin
  3. Database
  4. Ado.net sqldatareader not working

Ado.net sqldatareader not working

Scheduled Pinned Locked Moved Database
csharpasp-netdatabasesysadminhelp
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.
  • K Offline
    K Offline
    kal13na13
    wrote on last edited by
    #1

    Hi I am using asp.net in C# I am using sqldatareader where I am trying to select some rows from the (radiobuttonlist) from database and display in the datagrid which is not happening it gets stuck in the datareader.The action is taking place in the click button event the details to be displayed in the same and next page . here is the code SqlConnection conn=new SqlConnection("server=KHWA73R;database=NorthWind;user id=sa;password=sa"); string strSelect=("SELECT CustomerID,OrderID FROM Orders" + " WHERE CustomerID = '' " + Radiobuttonlist1.SelectedItem.Value + "ORDER BY OrderID"); SqlDataReader reader; SqlCommand mycmd=new SqlCommand(strSelect,conn); try { conn.Open(); reader=mycmd.ExecuteReader(); DataGrid2.DataSource=mycmd.ExecuteReader(); DataGrid2.DataSource=reader; DataGrid2.DataBind(); } catch(Exception se) { Response.Write("Exception.."+ se.StackTrace); } finally { conn.Close(); } if (Radiobuttonlist1.SelectedIndex > -1) { Label1.Text = "You selected: " + Radiobuttonlist1.SelectedItem.Text; } Label1.Text ="Customers ID " + Radiobuttonlist1.SelectedItem.Text; Server.Transfer("Print.aspx"); thanks kal13na13

    M 1 Reply Last reply
    0
    • K kal13na13

      Hi I am using asp.net in C# I am using sqldatareader where I am trying to select some rows from the (radiobuttonlist) from database and display in the datagrid which is not happening it gets stuck in the datareader.The action is taking place in the click button event the details to be displayed in the same and next page . here is the code SqlConnection conn=new SqlConnection("server=KHWA73R;database=NorthWind;user id=sa;password=sa"); string strSelect=("SELECT CustomerID,OrderID FROM Orders" + " WHERE CustomerID = '' " + Radiobuttonlist1.SelectedItem.Value + "ORDER BY OrderID"); SqlDataReader reader; SqlCommand mycmd=new SqlCommand(strSelect,conn); try { conn.Open(); reader=mycmd.ExecuteReader(); DataGrid2.DataSource=mycmd.ExecuteReader(); DataGrid2.DataSource=reader; DataGrid2.DataBind(); } catch(Exception se) { Response.Write("Exception.."+ se.StackTrace); } finally { conn.Close(); } if (Radiobuttonlist1.SelectedIndex > -1) { Label1.Text = "You selected: " + Radiobuttonlist1.SelectedItem.Text; } Label1.Text ="Customers ID " + Radiobuttonlist1.SelectedItem.Text; Server.Transfer("Print.aspx"); thanks kal13na13

      M Offline
      M Offline
      miah alom
      wrote on last edited by
      #2

      You cannot bind DataReader to the Winform DataGrid. This is possible in ASP.NET though. So please bing the DataGrid to a DataSet instead. Q313482 INFO: Roadmap for Windows Forms Data Binding http://support.microsoft.com/support/kb/articles/q313/4/82.asp

      K 1 Reply Last reply
      0
      • M miah alom

        You cannot bind DataReader to the Winform DataGrid. This is possible in ASP.NET though. So please bing the DataGrid to a DataSet instead. Q313482 INFO: Roadmap for Windows Forms Data Binding http://support.microsoft.com/support/kb/articles/q313/4/82.asp

        K Offline
        K Offline
        kal13na13
        wrote on last edited by
        #3

        hi is this possible in asp.net i am using asp.net with C# .Could you tell how it can be done thanks kal13na13

        M 1 Reply Last reply
        0
        • K kal13na13

          hi is this possible in asp.net i am using asp.net with C# .Could you tell how it can be done thanks kal13na13

          M Offline
          M Offline
          miah alom
          wrote on last edited by
          #4

          Check this out. http://www.sitepoint.com/article/asp-net-repeater-control

          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