Last post Dec 02, 2012 01:54 AM by Decker Dong - MSFT
Nov 29, 2012 11:57 AM|ret123|LINK
I changed the txtserachbox.text to SQL Ran so i know it has ran but the result still wont apper in the grid view
protected void btnsearch_Click(object sender, EventArgs e)
string conn_string = @"Provider=Microsoft.ACE.OLEDB.12.0;
Persist Security Info=False;";
using (OleDbConnection connection1 = new OleDbConnection(conn_string))
string query1 = "select * from song_tbl where sTitle = @searchQuary ";
OleDbCommand mySQLCommand1 = new OleDbCommand(query1, connection1);
myDataReader = mySQLCommand1.ExecuteReader();
if (myDataReader != null)
txtSearchbar.Text = "SQL Ran";
GridView1.DataSource = myDataReader;
txtSearchbar.Text = "No Matchfound";
Nov 29, 2012 12:04 PM|oned_gk|LINK
Nov 29, 2012 12:19 PM|ret123|LINK
Were will i put that code?....also imgetting a red line under .ExectueQuery();
Nov 29, 2012 12:33 PM|msmk|LINK
ExecuteNonQuery is used when no data is being returned, for example a delete, update or insert statement.
If data will be returned, use ExecuteReader. For example in your case where the select statement will return data. you already have this statement on the next line.
If only one cell is returned (ie. one 'peice' of data) you can use ExecuteScalar.
Nov 30, 2012 12:45 AM|Decker Dong - MSFT|LINK
First I'd like to say that I don't see anything obvious wrong with your codes……So please make sure that you GridView supports DataReader：
And you should notice that you cannot bind a DataReader directly to GridView, and you have to bind a DataTable to that.
If you wanna increase the speed, I think you can just try this by drag and drop a SqlDataReader onto the Web page, and then set its
DataSourceMode = DataReader.
Dec 01, 2012 07:33 PM|hans_v|LINK
Decker Dong - MSFT
And you should notice that you cannot bind a DataReader directly to GridView
Yes, you can!
Dec 02, 2012 01:54 AM|Decker Dong - MSFT|LINK
Please check whether your DataReader can really read out data from db.
Sorry I've mixed the concepts……