Sunday, July 8, 2012

Index ID incrementer for writing new Data to SQL using C# form



private void Form1_Load(object sender, EventArgs e)
        {
            SqlDataAdapter dataAdapter;
            DataSet dataSet;
            //IEnumerator iEnumerator;
            SqlConnection connection = new SqlConnection(Trial.Program.Globals.db.connectionString);
            dataAdapter = new SqlDataAdapter("select * from Cust", connection);
            dataSet = new DataSet();
            dataAdapter.Fill(dataSet);
            int rows = dataSet.Tables[0].Rows.Count;          
            //MessageBox.Show("No. of Rows are : " + rows.ToString());
            int rowcount = rows + 1;
            txtCustNo.Text = rowcount.ToString();
        }


this code helps to generate the index number which is there to to add data next... :)

No comments:

Post a Comment