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

  • Home
  • SEARCH
  • 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 8923391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:06:19+00:00 2026-06-15T07:06:19+00:00

i have problems with a sql command in mysql. I have a asp.net applcation

  • 0

i have problems with a sql command in mysql. I have a asp.net applcation and use a mysql database as database. I want to built a class that can insert,update,delete and select the records in the database. I have problems with the update command. In phpmyadmin it works but in my class not :/

Here is my code

public void UpdateRecord(string title, string firstname, string lastname, string company,
                               string timefrom, string timeto)
        {
            connection = new MySqlConnection();

            try
            {
                MySqlCommand command = connection.CreateCommand();

                //for testing
                string sql = "UPDATE 'tb_gast' SET FIRSTNAME='test' WHERE ID=270";

                command.CommandText = sql;

                connection.Open();

                command.ExecuteNonQuery();

            }
            catch (Exception)
            {

            }
            finally
            {
                connection.Close();
            }
        }

this command work in phpmyadmin

UPDATE `tb_gast` 
SET 
FIRSTNAME='uu',
LASTNAME='uu',
COMPANY='uu'
WHERE ID=270
  • 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-15T07:06:20+00:00Added an answer on June 15, 2026 at 7:06 am

    You are using single quote around the tablename, instead of backticks.
    The backtick could be typed using the key combination ALT+096

    UPDATE `tb_gast` SET FIRSTNAME = 'test' WHERE ID=270
    

    EDIT: Looking at your question more in deep.
    Noticed that you declare a MySqlConnection and initialize it WITHOUT any connection strings.
    If this is your real code no wonder that it doesn’t work

    This is how your code should be

            using(connection = new MySqlConnection(GetConnectionString())
            {
                connection.Open();
                using(MySqlCommand command = connection.CreateCommand();
                {
                    //for testing
                    string sql = "UPDATE `tb_gast` SET FIRSTNAME='test' WHERE ID=270";
                    command.CommandText = sql;
                    command.ExecuteNonQuery();
                }
            }
    

    where GetConnectionString() should be some method that returns your connection string from some permanent storage like a configuration file

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

Sidebar

Related Questions

How can I query the database culture (SQL Server 2005) ? I have problems
i am trying to use MySQL 5 and asp.net 4 i succeed withe the
I have this code, that uses mysqldump to backup mysql database. The problem is
Hey I have small problem but I can't fix it :( I use mysql
I have a fairly small MySQL database (a Textpattern install) on a server that
I was having problems updating information in my SQL database using my vb.net application,
So I am developing in Net Beans a MySQL/Java program for class that helps
I have a asp.net page in which I have a chart that I dragged
I have problems with this simple SELECT command, I've already selected which database in
I want to call a subprocess to backup mysql database. A command line which

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.