DataSource Controls :: Can't Delete Record From Database
Mar 5, 2010
I have 3 pages, one to add a category, one to edit the category, and one to delete the category. The add and edit work fine. The delete is not working for some reason. I click the link on my site to delete it, and I'm just staring at the green bar in my browser taking a long time. The add and edit don't take long at all to perform their function. I'm thinking this is a connection string issue, but I don't see how it can be the case. It relies on web.config for it just like the other pages. Following is the delete page code behind and also delete cascade from the business logic area. After the page refreshes, I'm not getting any diagnostics or error messages which I have in the code. Doesn't this have to mean a db connection issue?
I am counting from a table for that i have written code as below
protected void get_Id_Afterpoint() { int counter = 0; string strSql = "select count(*) as ID from tblEnergy where ID=?"; OdbcCommand com = new OdbcCommand(strSql, con); com.Parameters.AddWithValue("ID", DropDownList1.SelectedValue); OdbcDataAdapter oda = new OdbcDataAdapter(com); DataTable dt = new DataTable(); oda.Fill(dt); if (dt.Rows.Count == 0) { lblID2.Text = "1"; } else { counter = dt.Rows.Count; counter = counter + 1; lblID2.Text = Convert.ToString(counter); } }
there is no record related to DropDownList1.SelectedValue. but as i am counting if(dt.rows.count) and i put break point on the bolded part it shows 1 record. how it can be possible?
I have a table that have LibraryID and LibraryParentID.
LibraryID int Unchecked Name varchar(50) Checked Description varchar(200) Checked LibraryLevel int Checked LibraryParentID int Checked LibraryTypeID int Unchecked
I want to write a sql to delete the currrent select parent and well as all child record, how can I do that?
I am working with asp.net 2008 and sql server 2005 . I get a situation where i have to delete data after 30 days. a suitable query how to do the same. I have go through different query but nothing going right for me.
when i want insert a record i see an error like this Can't perform Create, Update, or Delete operations on 'Table(MainMenuLink)' because it has no primary key. with this codes:
MyLinqDataClassesDataContext db = new MyLinqDataClassesDataContext(); MainMenuLink li = new MainMenuLink { Link = "www.tprogrammer.com", LinkSubject = "subject" }; db.MainMenuLinks.InsertOnSubmit(li); [code]....
I have a form where users can subscribe and unsubcribe to my email list. so far, i have the subscribe button working fine "add member" function. Now i need help with my "delete member " function (unsubscribe button). it will allows the user to delete their record from the database. When I run the code and click the "unsubscribe" button, i can't get the logic correct so that it will delete the user's record if it exisit. here's the code i'm using for the subscribe and unsubscribe buttons
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class joinmailinglist : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void addMember(object sender, EventArgs e) { // here you are defining the classes for the database and the linq mailinglistClassDataContext Class = new mailinglistClassDataContext(); mailinglistMember member = new mailinglistMember(); // Now we are going to add the data to the member // Here we are going to let the system define a GUID for the unique user ID member.memberID = new Guid(); // here we are going to capture the user inputs and we are going to set these to lower case especially the email so that we can do a proper comparison later. member.fname = txtFirstName.Text; member.lname = txtLastName.Text; member.email = txtEmail.Text; // Here we are going to create the URL so we can later remove the user if they decide to opt out. member.removeurl = "http://removeuser.aspx?code=" + member.memberID.ToString(); // Here we are going to use a LINQ query to search the class of mailinglistmembers for any emails that contain equal values of the text field and select it. var duplicatecheck = from emails in Class.mailinglistMembers where emails.email.Contains(txtEmail.Text) select emails...............................
I created a ListView and attempted to delete a record using the delete button and native procedures. It failed and threw an error.Pass in a valid dictionary for delete or change your mode to OverwriteChangesIn researching this issue, it appeared there is a problem with the list view when deleteing and ConflictDetection is set to
I'm a beginner in programming and also to asp.net. I am trying to insert a row into an sql database using vb.net but I keep getting an error whenever I try to execute the code. I have read other post but I do not understand the solutions or how to place them within my code. Here is my stored procedure and vb.net code.
Is there anyone know the reason why that there duplicate data in the database most of the time the information is same like name,description.but the unique id is different and the date time is got different millisecond.I confirmed that there r no loop condition on the code.
Basically what i have is a button and i want this button to add value in database, i mean if the value in the database is 1 it adds 1 to it, so that the value becomes 2.
copying some data from an existing remote database(SQL2005) to an existing local database.First - I have very little experience in this area. I'm using Visual Web Developer 2008 (VB). Currently if I want to update some data in the local database I do something like this:
Dim conn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("CCCdbConnectionString").ConnectionString) Dim cmd As Data.SqlClient.SqlCommand = New Data.SqlClient.SqlCommand("UPDATE [Orders] Set [OrderStatus]
I want to retrive thousands of record from the database. Please tell me the the most efficient way to do this. I am using sql server. I want to bind A gridview with these records please let me know the most efficient way to do this so that the loading time for the page is reduced
My code is not updating the sql database. I am definately passing the correct information in to this function, and it runs without errors. If I exec the procedure with the passed in data, it works great. Can someone tell me what is missing?
I've have to delete multiple rows from database in a table . Which is the best way to delete data to optimize performance of sql server as well as asp.net.
I have a gridview with edit and delete parameters enabled. When I click on the edit link, I can edit the record successfully. However when I click on the delete link, nothing happens (the record does not get deleted).
I am creating an album using the following stored procedure, which returns the primary key for the newly created record:
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[fpa_sp_albums_update_insert] @album_id int, @album_name nvarchar (50), @album_descr nvarchar(250), @album_img_cover_id_FK int, @album_creation_date date AS If @album_id > 0 UPDATE [fpa_albums] SET album_name=@album_name, album_descr= @album_descr, album_img_cover_id_FK = @album_img_cover_id_FK, album_creation_date = @album_creation_date Where ((album_id = @album_id)) Else INSERT INTO [fpa_albums] ( album_name, album_descr, album_img_cover_id_FK, album_creation_date) VALUES ( @album_name, @album_descr, @album_img_cover_id_FK, @album_creation_date) Return SCOPE_IDENTITY();
I execute the above stored procedure using the SQLHELPER. The VB.NET code for the page is as follows:
[Code]....
However, the createdAlbumID always shows -1 instead of the id for the newly created album.
I am having a small issue i.e i am going to delete a record by using button. I have written confirm control for that. Now what i need is if i does not select any row from Grid view and click on delete i would like to raise like select atleast one record to delete can any one tell how to do..