G
Guest
Hi,
I have a dataGridView in my win Form, and i get some information from my
DataBase (sql) into a dataTable.
I tried and tried and i can't display my result in the dataGridView.
in addition, I also want to edit the columns (change the headr and size), i
know i can do it with the columns collection, but i need to bind each column
to a coulmn in my dataBase, and i don't know how to do it.
this is my code:
com = new SqlCommand();
da = new SqlDataAdapter();
// dt = new DataTable();
//
// com
//
this.com.CommandText = "[Get_Message_By_Person]";
this.com.CommandType = System.Data.CommandType.StoredProcedure;
this.com.Connection = m_mc.Get_dbcon().GetConn();
this.com.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
false, ((System.Byte)(10)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));
//
// da
//
this.da.SelectCommand = this.com;
System.Data.SqlClient.SqlParameter msg_to =
this.com.Parameters.Add(new System.Data.SqlClient.SqlParameter("@msg_to",
System.Data.SqlDbType.VarChar, 150));
msg_to.Value = employees_cb.Text;
da.Fill(msg_dt);
msg_dgv.DataSource = msg_dt;
thanks,
Gidi.
I have a dataGridView in my win Form, and i get some information from my
DataBase (sql) into a dataTable.
I tried and tried and i can't display my result in the dataGridView.
in addition, I also want to edit the columns (change the headr and size), i
know i can do it with the columns collection, but i need to bind each column
to a coulmn in my dataBase, and i don't know how to do it.
this is my code:
com = new SqlCommand();
da = new SqlDataAdapter();
// dt = new DataTable();
//
// com
//
this.com.CommandText = "[Get_Message_By_Person]";
this.com.CommandType = System.Data.CommandType.StoredProcedure;
this.com.Connection = m_mc.Get_dbcon().GetConn();
this.com.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
false, ((System.Byte)(10)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));
//
// da
//
this.da.SelectCommand = this.com;
System.Data.SqlClient.SqlParameter msg_to =
this.com.Parameters.Add(new System.Data.SqlClient.SqlParameter("@msg_to",
System.Data.SqlDbType.VarChar, 150));
msg_to.Value = employees_cb.Text;
da.Fill(msg_dt);
msg_dgv.DataSource = msg_dt;
thanks,
Gidi.