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.Comman dText = "[Get_Message_By_ Person]";
this.com.Comman dType = System.Data.Com mandType.Stored Procedure;
this.com.Connec tion = m_mc.Get_dbcon( ).GetConn();
this.com.Parame ters.Add(new
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4, System.Data.Par ameterDirection .ReturnValue,
false, ((System.Byte)( 10)), ((System.Byte)( 0)), "",
System.Data.Dat aRowVersion.Cur rent, null));
//
// da
//
this.da.SelectC ommand = this.com;
System.Data.Sql Client.SqlParam eter msg_to =
this.com.Parame ters.Add(new System.Data.Sql Client.SqlParam eter("@msg_to",
System.Data.Sql DbType.VarChar, 150));
msg_to.Value = employees_cb.Te xt;
da.Fill(msg_dt) ;
msg_dgv.DataSou rce = 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.Comman dText = "[Get_Message_By_ Person]";
this.com.Comman dType = System.Data.Com mandType.Stored Procedure;
this.com.Connec tion = m_mc.Get_dbcon( ).GetConn();
this.com.Parame ters.Add(new
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4, System.Data.Par ameterDirection .ReturnValue,
false, ((System.Byte)( 10)), ((System.Byte)( 0)), "",
System.Data.Dat aRowVersion.Cur rent, null));
//
// da
//
this.da.SelectC ommand = this.com;
System.Data.Sql Client.SqlParam eter msg_to =
this.com.Parame ters.Add(new System.Data.Sql Client.SqlParam eter("@msg_to",
System.Data.Sql DbType.VarChar, 150));
msg_to.Value = employees_cb.Te xt;
da.Fill(msg_dt) ;
msg_dgv.DataSou rce = msg_dt;
thanks,
Gidi.
Comment