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


            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();

            //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];


Recommended Answers

Answered by __avd 1,826 in a post from
dgvDAction.DataSource = ds.Tables["Action"];
Jump to Post
Answered by __avd 1,826 in a post from

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, learning, and sharing knowledge.