Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 自动完成文本框_C#_Sql Server_Windows_Visual Studio - Fatal编程技术网

C# 自动完成文本框

C# 自动完成文本框,c#,sql-server,windows,visual-studio,C#,Sql Server,Windows,Visual Studio,我的winform中有一个文本框。我想用客户表中的手机号码自动完成。我已经写了代码,但它不是自动完成的 string CS = "data source=.; database=BillingSoftware; user id=sa; Password=9495640"; SqlConnection con = new SqlConnection(CS); con.Open(); SqlCommand cmd = new SqlCommand

我的winform中有一个文本框。我想用客户表中的手机号码自动完成。我已经写了代码,但它不是自动完成的

   string CS = "data source=.; database=BillingSoftware; user id=sa; Password=9495640";
        SqlConnection con = new SqlConnection(CS);
        con.Open();
        SqlCommand cmd = new SqlCommand("SELECT Phone FROM Customers", con);
        SqlDataReader rdr = cmd.ExecuteReader();
        AutoCompleteStringCollection CustomerPhone = new AutoCompleteStringCollection();
        while (rdr.Read())
        {
            CustomerPhone.Add(rdr.GetString(0));
        }
        txt_customerPOS.AutoCompleteCustomSource = CustomerPhone;
        con.Close();
检查rdr.Read()是否有数据

或调用“电话”列名称

或致电rdr[“电话”]。ToString()