shahab Posted March 11, 2004 Posted March 11, 2004 Dear friends, I have heard that it is possible to populate data Grid by DataReader,� One-Is it possible at all? Two-What is the exact code? Cheers :D Quote
Moderators Robby Posted March 11, 2004 Moderators Posted March 11, 2004 Yes it is possible, you would use this method if you don't want data binding. (A few other reasons too :) ) I can't give you code, I'm sure someone else will. Quote Visit...Bassic Software
shahab Posted March 17, 2004 Author Posted March 17, 2004 I'm sure someone else will:) :D ???Who? Quote
mhsueh001 Posted March 17, 2004 Posted March 17, 2004 Why are you trying to do this with a data reader instead of just using a datatable or dataset? (There are a lot of code examples out there for this) A data reader is forward read only. I don't see any significant advantage of using a data reader? I was just curious as to why you want to use a data reader. Quote
shahab Posted March 18, 2004 Author Posted March 18, 2004 Speeding up the datagrid! It is realy faster than dataset & databind!:) Quote
LostProgrammer Posted March 18, 2004 Posted March 18, 2004 You still have to use databind. I have left out the reader in the code, you really don't need it. cmdSql = New SqlCommand(strSql, connSql) dgMyGrid.Datasource = cmdSql.ExecuteReader dgMyGrid.DataBind() -lp Quote
shahab Posted March 18, 2004 Author Posted March 18, 2004 I find it at last: void bindGrid1() { string strCon = ConfigurationSettings.AppSettings["ConnStr"]; SqlConnection objConn = new SqlConnection(strCon); objConn.Open(); //Create a command object for the query string strSQL =":)"; SqlCommand objCmd = new SqlCommand(strSQL, objConn); //Create/Populate the DataReader; SqlDataReader MyDR = objCmd.ExecuteReader(); DataGrid1.DataSource = MyDR; DataGrid1.DataBind(); } thanks to all Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.