コード例 #1
0
        private void button_refreshcompany_Click(object sender, EventArgs e)
        {
            this.input_forceDB.Checked = false;

            CompanyClass db = new CompanyClass();
            db.Server = this.input_server.Text;
            db.DbUserName = this.input_serveruserid.Text;
            db.DbPassword = this.input_serverpassword.Text;
            db.UseTrusted = this.input_usetrusted.Checked;
            db.language = BoSuppLangs.ln_English;
            Recordset rs;
            try
            {
                rs = db.GetCompanyList();

                DataTable myTable = new DataTable("companies");
                DataColumn dbItem = new DataColumn("dbName", Type.GetType("System.String"));
                DataColumn cmpItem = new DataColumn("cmpName", Type.GetType("System.String"));
                DataColumn versItem = new DataColumn("versStr", Type.GetType("System.String"));

                myTable.Columns.Add(dbItem);
                myTable.Columns.Add(cmpItem);
                myTable.Columns.Add(versItem);
                DataView firstView = new DataView(myTable);

                int companyCount = rs.RecordCount;
                rs.MoveFirst();
                DataRow NewRow;
                for (int c = 0; c < companyCount; c++)
                {
                    NewRow = myTable.NewRow();
                    NewRow["dbName"] = rs.Fields.Item("dbName").Value;
                    NewRow["cmpName"] = rs.Fields.Item("cmpName").Value;
                    NewRow["versStr"] = rs.Fields.Item("versStr").Value;
                    myTable.Rows.Add(NewRow);
                    rs.MoveNext();
                }
                this.input_company.DataSource = firstView;
                this.input_company.DisplayMember = "cmpName";
                this.input_company.ValueMember = "dbName";
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Failed to get company list (perhaps you should try DB direct):" + ex.Message);
                return;
            }
        }