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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:16:36+00:00 2026-05-26T04:16:36+00:00

Iam fairly new to SQLClient and all, and iam having a problem with my

  • 0

Iam fairly new to SQLClient and all, and iam having a problem with my SQL tables..when ever i run my code, the data, rather than getting updated, attaches itself to the already existing records in the tables..here’s my code

SqlConnection conneciones = new SqlConnection(connectionString);
SqlCommand cmd;
conneciones.Open();
//put values into SQL DATABASE Table 1
for (int ok = 0; ok < CleanedURLlist.Length; ok++)
{
     cmd = new SqlCommand("insert into URL_Entries values('" + CleanedURLlist[ok] + "' , '" + DateTime.Now + "' , '" + leak + "' )", conneciones);
     cmd.ExecuteNonQuery();
}
conneciones.Dispose();
  • 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-26T04:16:36+00:00Added an answer on May 26, 2026 at 4:16 am

    Take a look at these functions, i hope you understand better on update , insert and delete functions..

    Code snippets for reading, inserting, updating and deleting a records using asp.net and c# and sql server database

      static void Read()
      {
        try
        {
          string connectionString =
                "server=.;" +
                "initial catalog=employee;" +
                "user id=sa;" +
                "password=sa123";
            using (SqlConnection conn =new SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("SELECT * FROM EmployeeDetails", conn))
                {
                    SqlDataReader reader = cmd.ExecuteReader();
    
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("Id = ", reader["Id"]);
                            Console.WriteLine("Name = ", reader["Name"]);
                            Console.WriteLine("Address = ", reader["Address"]);
                        }
                    }
    
                    reader.Close();
                }
            }
        }
        catch (SqlException ex)
        {
            //Log exception
            //Display Error message
        }
    }
    
    static void Insert()
    {
        try
        {
            string connectionString =
                "server=.;" +
                "initial catalog=employee;" +
                "user id=sa;" +
                "password=sa123";
            using (SqlConnection conn =new SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("INSERT INTO EmployeeDetails VALUES(" +
                       "@Id, @Name, @Address)", conn))
                {
                    cmd.Parameters.AddWithValue("@Id", 1);
                    cmd.Parameters.AddWithValue("@Name", "Amal Hashim");
                    cmd.Parameters.AddWithValue("@Address", "Bangalore");
    
                    int rows = cmd.ExecuteNonQuery();
    
                    //rows number of record got inserted
                }
            }
        }
        catch (SqlException ex)
        {
            //Log exception
            //Display Error message
        }
    }
    
    static void Update()
    {
        try
        {
            string connectionString =
                "server=.;" +
                "initial catalog=employee;" +
                "user id=sa;" +
                "password=sa123";
            using (SqlConnection conn = ew SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd =
                new SqlCommand("UPDATE EmployeeDetails SET Name=@NewName, Address=@NewAddress WHERE Id=@Id", conn))
                {
                    cmd.Parameters.AddWithValue("@Id", 1);
                    cmd.Parameters.AddWithValue("@Name", "Munna Hussain");
                    cmd.Parameters.AddWithValue("@Address", "Kerala");
    
                    int rows = cmd.ExecuteNonQuery();
    
                    //rows number of record got updated
                }
            }
        }
        catch (SqlException ex)
        {
            //Log exception
            //Display Error message
        }
    }
    
    static void Delete()
    {
        try
        {
            string connectionString =
                "server=.;" +
                "initial catalog=employee;" +
                "user id=sa;" +
                "password=sa123";
            using (SqlConnection conn = ew SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd =
                    new SqlCommand("DELETE FROM EmployeeDetails " +
                        "WHERE Id=@Id", conn))
                {
                    cmd.Parameters.AddWithValue("@Id", 1);
    
                    int rows = cmd.ExecuteNonQuery();
    
                    //rows number of record got deleted
                }
            }
        }
        catch (SqlException ex)
        {
            //Log exception
            //Display Error message
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly new to WPF and I am having a problem with inheriting
I am fairly new to Linq To SQL but trying to run what should
I am fairly new to Git, and I am having a problem with doing
I am fairly new to C++ and I have seen a bunch of code
I am fairly new to WPF and am having trouble getting the DataTemplateKey to
I am fairly new to xslt (2.0) and am having some trouble with a
I am having a problem with what should be a fairly simple (I would
I am fairly new to LINQ. I am looking at this code, and not
I am fairly new to developing C/C++ code in MSVS but one of the
I am fairly new to MATLAB and I am having trouble figuring out an

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.