Ejemplo n.º 1
0
        private void cmdImport_Click(object sender, EventArgs e)
        {
            StreamReader  sr     = new StreamReader(File.OpenRead("Gens_SavestateData.csv"));
            List <string> lStats = new List <string>();

            while (!sr.EndOfStream)
            {
                lStats.Add(sr.ReadLine());
            }

            // finished importing stats
            //first is team name
            string[] sTemp;
            sTemp            = lStats[0].Split(',');
            lblAwayName.Text = sTemp[1];
            lblHomeName.Text = sTemp[2];

            try
            {
                // choose table to query against, using design time statement with parameter
                // return from query stored in this object
                nhl94DataSet.tblTeamsDataTable tbl = new nhl94DataSet.tblTeamsDataTable();
                // get adapter class object to run query
                nhl94DataSetTableAdapters.tblTeamsTableAdapter tAdapter = new nhl94DataSetTableAdapters.tblTeamsTableAdapter();
                // first param is object to store query results
                // second is what to search for in predefined statement
                tAdapter.FillByAbbrev(tbl, sTemp[1]);

                // can use object.rows as an array
                if (tbl.Rows.Count > 0)
                {
                    foreach (DataRow row in tbl.Rows)
                    {
                        MessageBox.Show("The full name is " + row[1] + " " + row[3]);
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
Ejemplo n.º 2
0
        private void settings_Load(object sender, EventArgs e)
        {
            // choose table to query against, using design time statement with parameter
            // return from query stored in this object
            nhl94DataSet.tblTeamsDataTable tbl = new nhl94DataSet.tblTeamsDataTable();
            // get adapter class object to run query
            nhl94DataSetTableAdapters.tblTeamsTableAdapter tAdapter = new nhl94DataSetTableAdapters.tblTeamsTableAdapter();
            // first param is object to store query results
            // second is what to search for in predefined statement
            tAdapter.FillJustTeamAbbrev(tbl);

            // can use object.rows as an array
            if (tbl.Rows.Count > 0)
            {
                cmbTeams.Items.Add("");
                cmbTeams.DataSource    = tbl;
                cmbTeams.DisplayMember = "sName";
                cmbTeams.ValueMember   = "sAbbrev";
            }
        }