Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   C# accessing dataset from multiple forms (http://www.go4expert.com/forums/c-sharp-accessing-dataset-multiple-forms-t28559/)

markyjj 10Jun2012 07:29

C# accessing dataset from multiple forms
I have a program where am trying to access a dataset in the main form from a 2nd Winfrom. I have created a form 1 ref but when I use this to access the datatable in the dataset it doesnt seem to work. The following code is for Form 2 and I Movset1 is the dataset in the main form. I then try to use a dataview to access the main dataset. Any help would be appreciated.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Common;

namespace MovieDiary
    public partial class Form2 : Form

        DataView Dv2 = new DataView();
        public Form2()

        public Form1 F1 = new Form1();

        public void Form2_Load(object sender, System.EventArgs e)

        private void label1_Click(object sender, EventArgs e)


        private void button1_Click(object sender, EventArgs e)
            if (textBox1.Text == "")
                MessageBox.Show(" Please enter a title to be deleted ");

            Dv2 = new DataView(F1.Movset1.Tables[0]);
            F1.dataGrid1.DataSource = Dv2;
            Dv2.RowFilter = "Title ='" + textBox1.Text + "'";

All times are GMT +5.5. The time now is 21:06.