-1

是否有可能针对 datagridview 或 gridview 运行 SQL 语句?

4

3 回答 3

0

You can make like this>>

 dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
   dataGridView1.AllowUserToAddRows = false;
    dataGridView1.AllowUserToDeleteRows = false;
    dataGridView1.AllowUserToOrderColumns = true;
    dataGridView1.ReadOnly = true;
   dataGridView1.MultiSelect = false;
    dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
    dataGridView1.AllowUserToResizeColumns = false;
    dataGridView1.ColumnHeadersHeightSizeMode = 
    DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
    dataGridView1.AllowUserToResizeRows = false;
    dataGridView1.RowHeadersWidthSizeMode = 
    DataGridViewRowHeadersWidthSizeMode.DisableResizing;

You can add columns by dataGridView1.Columns["CompanyName"].ReadOnly = true;

Can refer this>>http://msdn.microsoft.com/en-us/library/cze614bb.aspx

Or simply another way is keep your database table name and gridview name same.

于 2013-03-22T09:40:59.453 回答
0

No. But you can try using LINQ to objects instead.

于 2013-03-22T09:41:23.107 回答
0

请参考链接,它将 sql 转换为 Linq 到对象

取自以下:

在运行时将 SQL 转换为 Linq To Objects 表达式

希望这可以帮助

于 2013-03-22T10:05:03.220 回答