hey,

i have a problem in adding data from MS SQL(mdf file) database to datagrid view:
the code is below
please can someone help me with this.

C# Syntax

db.openConnection();

            String query4 = @"Select TActionDes,TAssignedTo,TDueDate,TStatus,TDateComplete,TComment From TopicAction Where TopicNo = @topicNo and Phase = @phase";
            SqlCommand command4 = new SqlCommand(query4, DB.getConnection());

            command4.Parameters.Add("@topicno", SqlDbType.VarChar).Value = TopicNo;
            command4.Parameters.Add("@phase", SqlDbType.Int).Value = Phase;

            SqlDataAdapter adapter4 = new SqlDataAdapter(command4);
            DataSet ds = new DataSet();

            adapter4.Fill(ds,"Action");
            //dgvDAction.DataSource = ds;


            int row = ds.Tables["Action"].Rows.Count - 1;

            for (int r = 0; r < row; r++)
            {
                dgvDAction.Rows[0].Cells[1].Value = ds.Tables["TActionDes"].Rows[r].ItemArray[1];
            
            }
            db.closeConnection();

thanxxxxxxx

Recommended Answers

All 5 Replies

dgvDAction.DataSource = ds.Tables["Action"];

i don't wnat it to data bound,
but to add detail cell by cell???????

can i add calender control to bound data in datagrid view??????????????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.