从表中读取数据时出现问题 [英] Problem in reading data from the table

查看:74
本文介绍了从表中读取数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个更新表的应用程序.在此应用程序中,我有一个组合框,可在其中加载记录的ID
加载表格时.让我粘贴我的代码以更清楚地了解我的问题.

Hello people,

I have an application that updates a table. In this application i have a combobox where i load id of record
on form load. Let me paste my code to be more clear about my problem.

Private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{

  string q = "Select AREA, [PAYING AUTHORITY],[PURCHASE ORDER No], [BILL No], [BILL DATED], [MATERIAL VALUE], [BILL VALUE], [AMOUNT PASSED] , [SUPPLY PARTICULAR], [PAYMENT DETAILS], [C-FORM No], T_ID  from transact1 where t_id = ''" +comboBox1.SelectedItem+ "'' ";

          SqlCommand cmmd = new SqlCommand(q, on6);

          SqlDataReader drr = cmmd.ExecuteReader();


         
          while (drr.Read())
          {
            //MessageBox.Show("Record With this Transaction Exist. Please Press OK to Continue.....");

            txtarea.Text = drr["AREA"].ToString();
            textBox2.Text = drr["PAYING AUTHORITY"].ToString();
            richdescp.Text = drr["PURCHASE ORDER No"].ToString();
            txtbill.Text = drr["BILL No"].ToString();
            dateTimePicker1.Text = drr["BILL DATED"].ToString();
            txtamt.Text = drr["MATERIAL VALUE"].ToString();
            txtamtpas.Text = drr["BILL VALUE"].ToString();
            textBox1.Text = drr["AMOUNT PASSED"].ToString();
            richrem.Text = drr["SUPPLY PARTICULAR"].ToString();
            txtchq.Text = drr["PAYMENT DETAILS"].ToString();
            textBox3.Text = drr["C-FORM No"].ToString();

            



          }
          drr.Close();
          


            on6.Close();
         
        }


        catch (Exception ex)
        {
          MessageBox.Show(ex.ToString());
        }
        }
}




每次我尝试以表格形式加载数据.它给我一个错误,即字符串未被识别为有效日期时间".
我尝试了很多事情,但没有帮助.有人可以帮我解决这个问题吗?

谢谢与问候
Ajinkya




Everytime i try to load data in the form. It gives me error that "String was not recognized as valid date time".
I tried lot of things but it didn''t help. Can anybody please help me with this problem?

Thanks and Regards
Ajinkya

推荐答案

也许您需要设置要放入dateTimePicker1.Text的文本的格式,以便控件将其识别为日期.
Perhaps you need to format the text you''re trying to put in dateTimePicker1.Text so that the control recognizes it as a date.


这篇关于从表中读取数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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