Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is the code below. but, i use the same code for other gird views it works like charm here it is showing this error why is that thanks in advance
C#
<pre lang="cs">public void searchbasedidadddetailsupdate()
        {
            try
            {
                con.Open();

                DataView view = new DataView();
                view.Table = ds.Tables[0];
                view.RowFilter = "Patient_ID = '" + txtupdatesearch.Text.Trim() + "'";
                dtvupdate.DataSource = view;

                if (dtvupdate.RowCount < 1)
                {
                    MessageBox.Show("Invalide ID! Please select Patient ID from the following combobox or try again", "Medi Alert Patien Care System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (MySqlException ms)
            {
                MessageBox.Show(ms.Message);
            }


            con.Close();
        }
Posted
Updated 19-Jun-14 7:09am
v2
Comments
ZurdoDev 19-Jun-14 13:08pm    
What's your question?
zakirox123 19-Jun-14 13:11pm    
when i try to trim the particular column based on patient ID from patient information which i have been already connected to the grid view but, it says no column found
ZurdoDev 19-Jun-14 13:17pm    
That means that ds.Tables[0] does not have a column named Patient_ID . Where is ds? You'll have to debug it to figure out why.
zakirox123 19-Jun-14 13:29pm    
Hi, every thing was ok it is showing the database on the particular grid view but, the problem is with the trim. my previous grid views are working perfect with the same code.
public void showdatabase()
{
con.Open();
da = new MySqlDataAdapter("select * from patientinformation", con);
ds = new DataSet();
da.Fill(ds);
dtvupdate.DataSource = ds.Tables[0];
con.Close();

}
ZurdoDev 19-Jun-14 13:36pm    
The only Trim you have is on a textbox. There is no way that is the issue.

1 solution

in theas two methods you are filling the same Dataset, which means after filling the second one, it's gonna overwrite what you had in the first data population.

C#
showdatabase();
           showchannelingdatabase();


Basically you need to update your code with the following :

namespace MediAlert.Patient
   {
       public partial class Patient_Details : Form
       {

           //database connection {
           private MySqlConnection con;
           private dbconnection dbcon = new dbconnection();
           private MySqlDataAdapter da;
           private DataSet ds = new DataSet();
           private MySqlDataReader dr;
           //}

           public Patient_Details()
           {
               InitializeComponent();
           }

           private void Patient_Details_Load(object sender, EventArgs e)
           {


               con = dbcon.openconnection();
               showdatabase();
               showchannelingdatabase();

           }

           public void showdatabase()
           {
               con.Open();
               da = new MySqlDataAdapter("select * from patientinformation", con);
              // ds = new DataSet();
               da.Fill(ds,"table0");
               dtvupdate.DataSource = ds.Tables["table0"];
               con.Close();

           }

           public void showchannelingdatabase()
           {

               con.Open();
               da = new MySqlDataAdapter("select * from channeling", con);
              // ds = new DataSet();
               da.Fill(ds, "table1");
               dgvchannelingupdate.DataSource = ds.Tables["table1"];
               con.Close();


           }

           public void searchbasedidadddetailsupdate()
           {
               try
               {
                   con.Open();

                   DataView view = new DataView();
                   view.Table = ds.Tables["table0"];
                   view.RowFilter = "Patient_ID = '" + txtupdatesearch.Text.Trim() + "'";
                   dtvupdate.DataSource = view;

                   if (dtvupdate.RowCount < 1)
                   {
                       MessageBox.Show(
                           "Invalide ID! Please select Patient ID from the following combobox or try again",
                           "Medi Alert Patien Care System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                   }
               }
               catch (MySqlException ms)
               {
                   MessageBox.Show(ms.Message);
               }


               con.Close();
           }

           public void searchbasedidupdate()
           {

               try
               {
                   con.Open();

                   DataView view = new DataView();
                   view.Table = ds.Tables["table1"];
                   view.RowFilter = "Channeling_ID = '" + cmbchannelingidupdate.Text.Trim() + "'";
                   dgvchannelingupdate.DataSource = view;

                   if (dgvchannelingupdate.RowCount < 1)
                   {
                       MessageBox.Show(
                           "Invalide ID! Please select Channeling ID from the following combobox or try again",
                           "Medi Alert Patien Care System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                   }
               }
               catch (MySqlException ms)
               {
                   MessageBox.Show(ms.Message);
               }


               con.Close();
           }
       }
   }
 
Share this answer
 
Comments
zakirox123 20-Jun-14 1:34am    
Wow thanks dude ;) Jafar :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900