![]() |
filter in datagrid and adocontrol |
Post Reply
|
| Author | |
tis707
Newbie
Joined: 28 January 2005 Status: Offline Points: 2 |
Post Options
Thanks(0)
Quote Reply
Topic: filter in datagrid and adocontrolPosted: 28 January 2005 at 4:18am |
|
here i struck up while doing my application
i am doing a small app which is MFC and SDI i used dialog box to insert edit boxes ,comboboxees and datagrid and ado control which binded what i need is if i entered any text in edit box and click on search button the result will be displyed in datagrid i mean sorting (ex: id i entered "p" in editbox the datagrid have to show the names staring with "p" void Dlg1::OnSearch() { CADODatabase* pAdoDb = new CADODatabase(); CString strConnection = _T(""); strConnection = _T("Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=C:\\Final\\employeeData.mdb"); pAdoDb->SetConnectionString(strConnection); if(pAdoDb->Open()) { CString strEmpFirstName; //GetDlgItem(IDC_EMPID)->GetWindowText(strEmpID); GetDlgItem(IDC_FIRSTNAME)->GetWindowText(strEmpFirstName) ; CString strQuery; strQuery = ("SELECT * FROM empMaster where FirstName='PRABHAT'"); //LIKE '%" + strEmpFirstName + "%'"; pAdoDb->Execute(strQuery); m_DataControl.Refresh(); pAdoDb->Close(); } delete pAdoDb; /*CString strEmpFirstName,strQuery; GetDlgItem(IDC_FIRSTNAME)->GetWindowText(strEmpFirstName) ; if(strEmpFirstName.IsEmpty()) { MessageBox("Enter First Name to serach"); GetDlgItem(IDC_FIRSTNAME)->SetFocus(); //C_Recordset.m_strSort= "LastName DESC, FirstName DESC"; strQuery = "SELECT * FROM empMaster where FirstName LIKE '%" + strEmpFirstName + "%'"; m_DataControl.ExecuteDlgInit(strQuery); m_DataControl.Refresh(); //GetDlgItem(IDC_ADODC1)->RecordSource = strQuery; }*/ //C_Recordset.m_DataControl= "LastName DESC, FirstName DESC"; // TODO: Add your control notification handler code here } |
|
|
tis
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |