|
Subject:
|
Problems In Deleting Record
|
|
Posted By:
|
nkrust
|
Post Date:
|
1/12/2007 6:57:19 AM
|
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..
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
|
|
Reply By:
|
dparsons
|
Reply Date:
|
1/12/2007 8:40:28 AM
|
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
|
|
Reply By:
|
nkrust
|
Reply Date:
|
1/12/2007 10:52:55 PM
|
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
|
|