C#Mysql gridview trim error找不到列[Patient_ID] [英] C# Mysql gridview trim error Cannot find column [Patient_ID]

查看:63
本文介绍了C#Mysql gridview trim error找不到列[Patient_ID]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是代码。但是,我使用相同的代码用于其他gird视图它像魅力这里显示此错误为什么是提前感谢

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

<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();
        }

推荐答案

在你填充相同数据集的两种方法中,这意味着在填充第二个数据集后,它会覆盖你在第一个数据填充中的内容。



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.

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();
           }
       }
   }


这篇关于C#Mysql gridview trim error找不到列[Patient_ID]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆