English 中文(简体)
查阅数据组的栏目,以获取价值?
原标题:loop a column in datagridview to get the value?

i am doing a project on web service and window form basically i meet some problem and not sure how to solve

  1. i 想通过网络服务在数据网格的每行各取数据,并输入数据基,以获得像这一行文1;第2行;第3行;第4卷......索一只花了路,但用面面面面面面图显示,以黑体表示。

    private void push_Click(object sender, EventArgs e)
    
    {
    
        string nominal;
    
        for (int i = 0; i < DGV.Rows.Count; i++)
        {
            nominal = Convert.ToString(DGV.Rows[i].Cells[1].Value);
    
        }
        WSBrand insertInto = new WSBrand();
        insertInto.Insert(**nominal**)
    }
    

这是我的插入方法。

[WebMethod]

public DataSet Insert(String BrandName)
{

    SqlCommand dbCommand = new SqlCommand();
    dbCommand.CommandText = "INSERT INTO Brand (BrandName)VALUES (@BrandName)";
    dbCommand.Connection = conn;
    da = new SqlDataAdapter();
    da.SelectCommand = dbCommand;
    dbCommand.Parameters.AddWithValue("@BrandName", BrandName);


    DataSet ds = new DataSet();
    da.Fill(ds);
    return ds;
}
最佳回答
private void push_Click(object sender, EventArgs e)
{    
    StringBuilder nominal = new StringBuilder();
    for(int i = 0;i<DGV.Rows.Count;i++){
        nominal.Append(Convert.ToString(DGV.Rows[i].Cells[1].Value) + ";");
    }
    WSBrand insertInto = new WSBrand();
    InsertInto.Insert(nominalList); 
}

在贵族学校:

    [WebMethod]
public DataSet Insert(string nominal)
{        
    SqlCommand dbCommand = new SqlCommand();
    dbCommand.CommandText = "INSERT INTO Brand (BrandName)VALUES (@BrandName)";
    dbCommand.Connection = conn;
    dbCommand.Parameters.AddWithValue("@BrandName", sb.ToString());
    dbCommand.ExecuteNonQuery();

    SqlCommand dbCommand2 = new SqlCommand();
    dbCommand2.CommandText = "SELECT * FROM Brand";
    dbCommand2.Connection = conn;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = dbCommand2;
    dbCommand2.ExecuteNonQuery();

    DataSet ds = new DataSet();
    da.Fill(ds);
    return ds;
}

问题在于,名义上在 lo的每一个角落都是虚构的。 如果你制定一份载有全球价值链所有价值观的扼杀清单,那么,在你们的WSBrand类别中,就更容易查阅。

EDIT:当你执行INSERT声明时,将返回的唯一东西是受影响的浏览次数。 为了获得所有数据,你必须执行从Brands query处获得的选任证书,使你能够用数据填写数据集!

最后,《经济、社会、文化权利国际公约》:这应当充满希望。 我改变了推力。 浮标方法和插入方法。 如果存在任何yn错,你就不得不做这些事,就像我在笔记本中所做的那样。 Good Luck

问题回答

Simply use foreach loop:

foreach(DataGridviewRow a in DGV.Rows)
{
 string  nominal = Convert.ToString(a.Cells[1].Value)

    WSBrand insertInto = new WSBrand();
    insertInto.Insert(nominal)

}




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签