This is what my form looks like, and my code looks like this:
using System.Data.SqlClient;
namespace ProjectCSharpSQLserver
{
public partial class Form1 : Form
{
SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=I:\ProjectCSharpSQLserver\ProjectCSharpSQLserver\CsSQL.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand();
DataTable dt = new DataTable();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
cn.Open();
SqlDataAdapter sda = new SqlDataAdapter("insert into info (id, Name, phone, Address) Values ('" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "')", cn);
sda.Fill(dt);
cn.Close();
}
}
}
I need to know how to open the combobox, find the Id, choose one and then then textboxes get populated by the data from the db, so I can delete and update data.