This is A C# Practice code:
Video For Result:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace dataentry
- {
- public partial class UserLogin : Form
- {
- public UserLogin()
- {
- InitializeComponent();
- }
- SqlConnection asdf = new SqlConnection("Data Source=.;Initial Catalog=dataentry;Integrated Security=True;Pooling=False");
- private void button1_Click(object sender, EventArgs e)
- {
- SqlDataAdapter data = new SqlDataAdapter("Select sum("+comboBox1.Text+") from Register", asdf);
- DataTable ss = new DataTable();
- data.Fill(ss);
- dataGridView1.DataSource = ss;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- SqlDataAdapter data = new SqlDataAdapter("Select avg(" + comboBox1.Text + ") from Register", asdf);
- DataTable ss = new DataTable();
- data.Fill(ss);
- dataGridView1.DataSource = ss;
- }
- }
- }
Facebook Comment