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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:33:00+00:00 2026-06-04T19:33:00+00:00

I have a database, I think when I initially generated it, I didn’t bother

  • 0

I have a database, I think when I initially generated it, I didn’t bother to select the “Generate Delete function” option and now I find myself wanting to add that in.

Currently, I have a gridview bound to the database with a delete button for each row. It seems like I should be able to just run a custom delete function with the following code;

protected void gvUsers_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    using (SqlConnection conn = new SqlConnection(database.ConnectionString))
    {
        SqlCommand command = conn.CreateCommand();
        command.CommandText = "DELETE FROM userlist WHERE Username='@insUsername'";
        command.CommandType = System.Data.CommandType.Text;

        command.Parameters.Add(new SqlParameter("insUsername", gvUsers.Rows[e.RowIndex].Cells[1].Text));

        conn.Open();
        command.ExecuteNonQuery();
    }
}

I had no issues when using the above code as an insert function…I think it has something to do with the fact that the button is part of the GridView? At the moment I get; Deleting is not supported by data source ‘database’ unless DeleteCommand is specified.

Any help on this would be great, thanks.

  • 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-04T19:33:02+00:00Added an answer on June 4, 2026 at 7:33 pm

    You can put SQL into the DeleteCommand and not just a procedure name…

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.deletecommand.aspx shows how this is done but the key line is:

    DeleteCommand="DELETE FROM [Order Details] WHERE OrderID=@OrderID;DELETE FROM Orders WHERE OrderID=@OrderID;"
    

    This should get around the problem of it not allowing delete without a deletecommand. 🙂

    Edit to add:

    One other alternative that I found suggested that that error is thrown after that function is run when it comes to pass the delete on. You can use e.Cancel=true to cancel the delete event after you have done the delete yourself. Source

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

Sidebar

Related Questions

I think my scenario is pretty common. I have a database and I want
I have a VB app that accesses a sql database. I think it’s running
Using oracle database. Here's how i think the SQLException happens... Say i have two
i have DataBase function that calculate distance by coordinates CREATE OR REPLACE FUNCTION distance(lat1
I have a process that's going to initially generate 3-4 million PDF files, and
One thing I have continually found very confusing about using an object database like
I have database application, I want to allow the user to restore the deleted
I have Database with date field. I see the time like: 1900-01-01 13:38:00.000 How
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have database, and in one the tables I need change the values of

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.