Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2007, 07:57 AM
Authorized User
 
Join Date: Mar 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems In Deleting Record

Hi,
I'm trying to Delete a record in a table but its not getting deleted.. i'm listing the code below. I suppose there's some mistake .. but not sure where..
Code:
MyReportTableAdapter myReports = new MyReportTableAdapter();
myReports.DeleteReport(ID, "Report"); //ID is string

------
This is the code to access the DB in the xsd file

<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="True">
<CommandText>DELETE FROM TblMyRpts WHERE     (MUserID = :UserID) 
        AND (MRptId =  (SELECT  RptID FROM TblRpts   WHERE   (RptName = :ReportName)))
</CommandText>
<Parameters>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="UserID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
<Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="ReportName" Precision="0" Scale="0" Size="0" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</DeleteCommand>
------------------------------------------------------------------------------------------------------------
Adventure, Play, Alive, Fast, Race, Addict, React, Attack, Heat, Aggression, Blast, Ahead, Escape, Challenge, Anarchy, Game, Real, Damage, Insane, Acclerate,Passion, Fear, Dominate, Crazy, Awesome, Sweat, Habit, Avenge, Balls, Imagine, Viril, Chaos, Amuse, Heavy, Panic, @#!%, Fanatic
__________________
------------------------------------------------------------------------------------------------------------
<b><i>Adventure, Play, Alive, Fast, Race, Addict, React, Attack, Heat, Aggression, Blast, Ahead, Escape, Challenge, Anarchy, Game, Real, Damage, Insane, Acclerate,Passion, Fear, Dominate, Crazy, Awesome, Sweat, Habit, Avenge, Balls, Imagine, Viril, Chaos, Amuse, Heavy, Panic, @#!%, Fanatic </i></b>
 
Old January 12th, 2007, 09:40 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

If a record isn't deleteing it is probably because of your WHERE statement being incorrect. Are you sure that the above code is actually connecting to the database? Have you printed out the SQL statement to verifiy the row you are trying to delete actually exists in the database?

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old January 12th, 2007, 11:52 PM
Authorized User
 
Join Date: Mar 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The query is correct as it works when i directly run it on the database. I'm sure this is the code that's connecting to the db, i just copy pasted it from the .xsd file. And yes the row is present in the DB, strangely enough if instead of the inner query i give the RptId directly it works, so i assume its something else that i might b overlooking. If there's another way to do it please let me know.

------------------------------------------------------------------------------------------------------------
Adventure, Play, Alive, Fast, Race, Addict, React, Attack, Heat, Aggression, Blast, Ahead, Escape, Challenge, Anarchy, Game, Real, Damage, Insane, Acclerate,Passion, Fear, Dominate, Crazy, Awesome, Sweat, Habit, Avenge, Balls, Imagine, Viril, Chaos, Amuse, Heavy, Panic, @#!%, Fanatic





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems deleting a record donrafeal Access VBA 0 January 18th, 2007 06:19 PM
Deleting All Record In A Table McDiddy Access VBA 3 January 10th, 2007 09:20 AM
Deleting A Record sirmilt BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 July 31st, 2006 07:12 PM
Confirm before deleting record jgrasso BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 March 30th, 2005 12:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.