hello,
i m working on connecting sqlData with C# form
showing data detail on text boxess like ID,name,occupation.and doing the search by entering the ID on textbox then clicking the button to show the details
i'm just a beginner in C#
so i did the the coding like this and it is full of mistakes can u plz help me and tell me how can i do this
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("Data Source=C:=Users=....");
cmd = new SqlCommand("select * from finalTest where ID = '"+textbox1.text+"'",cn);
cn.Open();
dr = cmd.ExecuteReader();
while (dr.Read());
{
TextBox2.text(dr[ID].ToString());
TextBox3.text(dr[firstName].ToString());
TextBox4.text(dr[occupaion].ToString());
}
dr.Close();
cn.Close();
}
}
}