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 8355795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:58:24+00:00 2026-06-09T09:58:24+00:00

I have been trying to add new information to my database from a Windows

  • 0

I have been trying to add new information to my database from a Windows Form (Gridview). This is the method I came up with (but it doesn’t work):

private void agregarProducto(string id_producto, string id_proveedor, string id_categoria, string cantidad, string precio_actual, string codigo_barras)
{
    MySqlCommand cmd = new MySqlCommand();

    using (cmd = cn.CreateCommand())
    {
        cmd.CommandText = "INSERT INTO productos(id_producto, id_proveedor, id_categoria, cantidad, precio_actual, codigo_barras) VALUES (@id_producto, @id_proveedor, @id_categoria, @cantidad, @precio_actual, @codigo_barras)";
        cmd.CommandType = CommandType.Text;

        cmd.Parameters.AddWithValue("@id_producto", tbId_Prod);
        cmd.Parameters.AddWithValue("@id_categoria", tbId_categoria);
        cmd.Parameters.AddWithValue("@id_proveedor", tb_Id_proveedor);
        cmd.Parameters.AddWithValue("@cantidad", tbCantidad);
        cmd.Parameters.AddWithValue("@precio_actual", tbPrecioActual);
        cmd.Parameters.AddWithValue("@codigo_barras", tbCod_barras);

        cn.Open();
    }
}

This is the event that’s is supposedly calling it:

private void btAgregarNuevo_Click(object sender, EventArgs e)
{
    agregarProducto(tbId_Prod.Text, tb_Id_proveedor.Text, tbId_categoria.Text, tbCantidad.Text, tbPrecioActual.Text, tbCod_barras.Text);
}

Am I missing something?

  • 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-06-09T09:58:26+00:00Added an answer on June 9, 2026 at 9:58 am

    You haven’t executed the sql. Do this after you open the connection

    cmd.ExecuteNoneQuery();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At www.euroworker.no/order I have been trying to add a tooltip function but it seems
I'm trying to add a new entry into my database, but it's not working.
I have been trying to add onclick event to new elements I added with
I have been trying this for a good while now but I can't seem
Im new to .NET and have been searching on this issue but no luck.
First off I'm new to Android and Java.. I have been trying to add
I have been trying to add an askquestion dialog box to a delete button
I have been trying to add to the Watch window a Java Date object
I have been trying and trying and looking for ways/tutorials on how to add
I want to add a thumbnail picture viewer to my application.I have been trying

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.