Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[C#] Query Search to Datagrid

puuts

Proficient
Advanced Member
Messages
210
Reaction score
0
Points
26
Hello,

Mga boss, can you please check my below code why it display no data in my datagrid?


I have class
Code:
class mdlDashboard : OM.DashboardHyperion


In my class DashboardHyperion
Code:
#region DATASOURCE FOR SEARCH DASHBOARD REPORTS


        public virtual DataSet SEARCH_DatasetSource(string strWhere)
        {


            if (strWhere != null) strWhere = " WHERE " + strWhere;
            

            OleDbDataAdapter dap = new OleDbDataAdapter(cmd);

            cmd.CommandText = "SELECT * FROM " + this.TableName + strWhere;
            cmd.CommandType = CommandType.Text;
            cmd.Connection = cn;

            try
            {

                ds.Clear();
                dap.Fill(ds, "dg_Completed");


            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                dap = null;
                cn.Close();
            }

            return ds.Copy();
        }



        #endregion


In my TextChanged event
Code:
private void txt_Dashboard_Search_TextChanged(object sender, EventArgs e)
{

HYPERION_.MODEL.mdlDashboard myMDL = new HYPERION_.MODEL.mdlDashboard();
this.dg_Report.AutoGenerateColumns = false;
this.dg_Report.DataSource = myMDL.SEARCH_DatasetSource("Report_Name LIKE '%" + this.txt_Dashboard_Search.Text + "%'");

}

Actually, niddisplay nya sa datagrid kung ilan ung nasearch, kaso blanko lng.
View attachment 203368
 

Attachments

  • SYM1.jpg
    SYM1.jpg
    38 KB · Views: 4
Last edited:
Sir baka nag return null yung commandtext nyo dahil dito.

OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
cmd.CommandText = "SELECT * FROM " + this.TableName + strWhere;
cmd.CommandType = CommandType.Text;
cmd.Connection = cn;

try nyo po sa baba i instantiate yung adapter nyo ganito

cmd.CommandText = "SELECT * FROM " + this.TableName + strWhere;
cmd.CommandType = CommandType.Text;
cmd.Connection = cn;
OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
 
Sir baka nag return null yung commandtext nyo dahil dito.

OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
cmd.CommandText = "SELECT * FROM " + this.TableName + strWhere;
cmd.CommandType = CommandType.Text;
cmd.Connection = cn;

try nyo po sa baba i instantiate yung adapter nyo ganito

cmd.CommandText = "SELECT * FROM " + this.TableName + strWhere;
cmd.CommandType = CommandType.Text;
cmd.Connection = cn;
OleDbDataAdapter dap = new OleDbDataAdapter(cmd);

still not working.
 
Check mo yung data ng cmd.CommandText if meron result yung query
 
Back
Top Bottom