Yo dude, you can always just refresh the connection, you don't need to close your form,
i take it you want something like this
using System.Data.SqlClient;
namespace TestDummyTWO
{
public partial class Form1 : Form
{
SqlConnection sqlcon =
new SqlConnection("Data Source=.;Initial Catalog=your_table;Integrated Security=True;Asynchronous Processing = True");
SqlCommand sqlCom = new SqlCommand("SELECT ITEMS FROM YOUR_TABLENAME");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SqlDataReader reader = sqlCom .ExecuteReader();
// Looping throuhg the list of data
while (reader.Read())
{
// Fill combo Box with data
comboBox1.Items.Add(reader["ITEMS"]);
}
}
private void button1_Click(object sender, EventArgs e)
{
// you added the new item from the tex box into the DATA TABLE
// Not the combobox
// use sqlCom again to do so
sqlCom.CommandText = "Insert into blah blah";
/* THIS IS WHAT YOU HAVE TO DO */
sqlcon.Close();
sqlcon.Open();
}
Hope that helps ...
Last edited by cVz; Jan 6th, 2009 at 4:11 am.
Delphi & C# programmer deluxe...