2017-11-15 5 views
0

私はコンボボックスでC#とアクセス2017を使用してオートコンプリートを作成したいと思います。私はこのコードを使用しました...しかし、私は "& lt"と "& gt"の平均を理解できません。これらの場所にはいくつかのエラーがあります。このエラーを修正するのを手伝ってください。C#とAccess 2017を使用してコンボボックスのオートコンプリート用のコードは何ですか?

private void Autocomplete() 
    { 
     string query; 
     OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|/Neth1.accdb"); 
     //opening connection 
     con.Open(); 
     try 
     { 
     //initialize a new instance of sqlcommand 
     OleDbCommand cmd = new OleDbCommand(); 
     //set a connection used by this instance of sqlcommand 
     cmd.Connection = con; 
     //set the sql statement to execute at the data source 
     cmd.CommandText = query; 

      OleDbDataAdapter da = new OleDbDataAdapter(); 
     //set the sql statement or stored procedure to execute at the data source 
     da.SelectCommand = cmd; 
     //initialize a new instance of DataTable 
     DataTable dt=new DataTable(); 
     //add or resfresh rows in the certain range in the datatable to match those in the data source. 
     da.Fill(dt); 


     foreach (DataRow r in dt.Rows) 
     { 
     //getting all rows in the specific field|Column 
     var rw = r.Field < string >("IMEI"); 

     //Set the properties of a combobox to make it auto suggest. 
     comboBox1.AutoCompleteMode = AutoCompleteMode.Suggest; 
     comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource; 
     //adding all rows into the combobox 
     comboBox1.AutoCompleteCustomSource.Add(rw); 

     } 
     } 
     catch (Exception ex) 
     { 
      //catching error 
      MessageBox.Show(ex.Message); 
     } 
     //release all resources used by the component 
     da.Dispose(); 
     //clossing connection 
     con.Close(); 
    } 

答えて

0

< =未満

> =より大きい

var rw = r.Field < string >("IMEI"); 

var rw = r.Field<string>("IMEI"); 
なります
関連する問題