Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6071217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:01:20+00:00 2026-05-23T10:01:20+00:00

i am doing a project on web service and window form basically i meet

  • 0

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

  1. i want to get the data in every row in ColA of datagridview and inside into the data base through web service, to get something like this row1;row2;row3;row4……so i did a for loop but at underline with the nominal which i highlight in bold

    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**)
    }
    

this is my insert method

[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;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:01:20+00:00Added an answer on May 23, 2026 at 10:01 am
    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); 
    }
    

    In Your WSBrand Class:

        [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;
    }
    

    The problem is that nominal is being overwritten in every iteration of the for loop. If you create a List of strings that contain all the values of the DGV then it will be easier to access them all in your WSBrand class.

    EDIT: When you are executing the INSERT Statement the only thing that will be returned is the number of rows affected. To get all the data back you must execute a SELECT * FROM Brands query and that will enable you to fill your Dataset with data!

    Final EDIT: This should work hopefully. I have changed both the push_Click method and the Insert Method. If there are any syntax errors you will have to work these out as I done this in notepad. Good Luck

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently doing a CRUD project for school and basically they want us
I'm starting a Web Application project in Java and I've been doing some research
I have a small project I am doing in Python using web.py. It's a
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
I am doing project euler question 33 and have divised a refactor to solve
I am doing a project where I want a person to enter the name
My project invoves a user connecting from client to web service, and then web
I am doing a project of web application. I am still a beginner and
Is there some way to take SOAP web service classes creates with JAX-WS and
I have a Windows forms project and a Web Service project in my solution,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.