private void btnDisplay_Click(object sender, EventArgs e) { mycommand = mycon.CreateCommand(); if (cmbTerm.SelectedIndex == -1) { mycommand.CommandText = "DisplayScore '" + App_Code.ShareClass.ID + "','0'"; } else { mycommand.CommandText = "DisplayScore '" + App_Code.ShareClass.ID + "','" + cmbTerm.SelectedItem + "'"; } myds = conclass.getDataSet(mycommand.CommandText, "Score"); // MessageBox.Show(cmbTerm.SelectedItem.ToString()); dataGridView1.DataSource = myds.Tables["Score"]; }
private void Init() { string sqlstr = "select * from Student where ID='" + txtID.Text.Trim() + "'"; App_Code.ConnectionClass myconnection = new App_Code.ConnectionClass(); DataSet myDataSet = myconnection.getDataSet(sqlstr, "Student"); txtName.Text = myDataSet.Tables["Student"].Rows[0]["StudentName"].ToString(); txtPhone.Text = myDataSet.Tables["Student"].Rows[0]["Phone"].ToString(); txtIdenID.Text = myDataSet.Tables["Student"].Rows[0]["IdentityID"].ToString(); txtAddress.Text = myDataSet.Tables["Student"].Rows[0]["Address"].ToString(); string sex = myDataSet.Tables["Student"].Rows[0]["Sex"].ToString(); if (sex == "男") { rbMale.Checked = true; } else { rbFemale.Checked = true; } }