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 search
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=dataentry;Integrated Security=True");
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- if (comboBox1.Text == "ID")
- {
- SqlDataAdapter sda = new SqlDataAdapter("SELECT CUS_ID, CUS_NAME, MOB_NO, CITY, LAND_LINE_NO, ADDRESS FROM CUS_ENTRY where cus_id like '"+textBox1.Text+"%'", con);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- dataGridView1.DataSource = dt;
- }
- else if (comboBox1.Text == "Name")
- {
- SqlDataAdapter sda = new SqlDataAdapter("SELECT CUS_ID,CUS_NAME, MOB_NO, CITY, LAND_LINE_NO, ADDRESS FROM CUS_ENTRY where CUS_NAME like '"+textBox1.Text+"%'", con);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- dataGridView1.DataSource = dt;
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- }
- }
Facebook Comment