Ado.net sqldatareader not working
-
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
-
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
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
-
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
-
Check this out. http://www.sitepoint.com/article/asp-net-repeater-control