本文介绍了用于数据类型的SqlDataReader和SelectedItem在Combobox中的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有这个代码应该读取数据类型Time然后SelectItem,但它没有选择Item。我该怎么改变它?谢谢!

这是我填写它的方式:

  void  vypl_comboboxy( )
{


spojeni.Open();
var cb1 = new SqlCommand( SELECT odjezd FROM stanice WHERE akce ='
+ selectrowid + 'ORDER BY odjezd ASC,spojeni);
SqlDataReader dr1 = cb1.ExecuteReader();
while (dr1.Read())
{
comboBox1.Items.Add(dr1 [ odjezd]);

}
dr1.Close();
dr1.Dispose();



这就是我想要在数据类型中选择项目的时间

 SqlCommand novyprikaz =  new  SqlCommand(  SELECT * FROM klient WHERE ID_K = + selectrowid,spojeni); 
spojeni.Open();
SqlDataReader precti = novyprikaz.ExecuteReader();

if (precti.Read())
{
comboBox1.SelectedItem = precti.GetTimeSpan( 16 )的ToString();
}
解决方案

Hello guys,
I have this code which should read data type Time and then SelectItem,but it doesn't select Item. How should I change it ? thanks!
This is how I fill it:

void vypl_comboboxy()
        {
            

                spojeni.Open();
                var cb1 = new SqlCommand("SELECT odjezd FROM stanice WHERE akce='"
                                + selectrowid+ "' ORDER BY odjezd ASC", spojeni);
 SqlDataReader dr1 = cb1.ExecuteReader();
                while (dr1.Read())
                {
                    comboBox1.Items.Add(dr1["odjezd"]);

                }
                dr1.Close();
                dr1.Dispose();


This is how I want to select item in data type Time

SqlCommand novyprikaz = new SqlCommand("SELECT * FROM klient WHERE ID_K=" + selectrowid, spojeni);
                spojeni.Open();
                SqlDataReader precti = novyprikaz.ExecuteReader();

                if (precti.Read())
                {
 comboBox1.SelectedItem = precti.GetTimeSpan(16).ToString();
}
解决方案


这篇关于用于数据类型的SqlDataReader和SelectedItem在Combobox中的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 13:00