public partial class goruntule : Form
{
SqlDataAdapter da = null;
DataSet ds = null;
SqlCommandBuilder cmdBuilder;
DataSet changes;
public goruntule()
{
InitializeComponent();
}
private void goruntule_Load(object sender, EventArgs e)
{
label1.Text = PERSONEL_TAKIP.main_form.goruntulenecek_tablo;
DataTable dtusers = new DataTable();
da = new SqlDataAdapter("SELECT * FROM " + PERSONEL_TAKIP.main_form.goruntulenecek_tablo, PERSONEL_TAKIP.main_form.myConnection);
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
private void button2_Click(object sender, EventArgs e)
{
try
{
cmdBuilder = new SqlCommandBuilder(da);
changes = ds.GetChanges();
if (changes != null)
{
da.Update(changes);
}
MessageBox.Show("Changes Done");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message +ex.Source);
}
}
If i use Datatable instead of Dataset up on my code GridView works fine. But i need to use dataset because Dataset can update my database (sql server 2008) with this method : da.Update(changes). I don't know if it can update my database, i just read it on many sites. Anyway why my code does not works ? Visual Studio does not give me an error or something. when program works the datagridview1 is blank when i use dataset like the code i send you. But if i use datatable, datagridview1 shows me the results from my sql command.
I would be happy if you can help me...
Thank you!