DataSource Controls :: Stored Procedure For Delete Records From Parent And Child Table
Jan 16, 2010
I have two tables dept and employees those table have parent and child relation ship link column is deptno i want to delte department even this departmetn contains employees i want to write storedprocedure for first delte employees and after department if i wrtie these two querys in storedprocedure will i get any problems
Delete from tbl_employees where Department_Id=@Department_Id
Delete from tbl_Department where Department_Id=@Department_Id
i am trying to delete using Gridview from child first and check if there is no child to delete in parent table i am using sql datasource in the delete tab in sql datasource i put DELETE FROM table1 WHERE (IDtable = @IDtable) IF (SELECT count(*) FROM table1 WHERE parent_dtl_id = 66) =0 BEGIN delete from parent_dtl where order_dtl_id= 66 END
i deleted all items,deleting from 2 tables child and parent was successfully on the last row from gridview but i have this error on my page on the last delete Specified argument was out of the range of valid values. Parameter name: value
I need to be able to delete records from a gridview using a stored procedure. My data comes from two sources so the standard delete won't work. I have come up with the code below which deletes a record, but the wrong one. How can I iterate through the rows to delete the row I actually want to delete.
I have a table that needs sorting by its hierarchial structure of parent-child.
An example of my table is below
As you can see above, my table structure follows this pattern
My overall aim is to have the sql order the table for me, and by using this new "depth" column, I will be able to indent by categories in the menu on the front end, you have probably seen this before, but all the tutorials I have read dont really explain it very well, or assume you are sql savvy.
I've written a stored procedure which uses a table variable. The stored procedure is shown below:
The table variable @CaseNumbers is declared, and is a bunch of values are inserted using a table-valued function called SplitStringIntoInts. At this point I can select from @CaseNumbers and this works fine.But when I try to join onto @CaseNumbers, the name '@CaseNumbers' in the ON clause is highlighted with the error 'Must declare scalar variable @CaseNumbers'. What?! It's not scalar, I declared it ages ago and I have used it since!
my stored procedure is always extract some data into temp table such as"select name,address,content into #TEMP1 from table1,table2,table3" finally, select another table together with #TEMP1 to extract all desire data from one queryselect T.name,T.address,T.content,C.other from #TEMP1 T, otherTable C where T.ID=C.IDI would like to ask if i want to join one more table T2 into final query with "otherTable left C outer join on C.ID=T2.ID"
i m using ##Temp Table in stored procedure..it gives this error There is already an object named '##people' in the database.in two codition1.in case of multisession2. if transaction drop in between even i drop Table in Last in stored procedure..what can i use in place of temp table to hold data for a time being
This may not be the correct place to put this as it is both a stored procedure AND Visual Studio 2008 problem.
I have the following stored procedure:
I have been mokeying around with it because of what is happening. I have a dataset, call it dataset1. I drag this stored procedure onto the dataset. I EXPECT a datatable to appear, instead the data set adds this store procedure to the queries table adapter and sets the exec mode to 'NonQuery' which unless I am very mistaken, means "don't expect a dataset back from this' when in fact you DO expect a dataset back from this.
The SQL server is a Windows 2000 Server running SQL 2000. It has never caused us a moments grief since we set it up oh-so-many years ago.
If I connect to a different database and drag a query into the same dataset I get a datatable as I expect. I cannot see where / how this procedure could be wrong. The query when executed returns exactly the data I expect, in the format I expect (looks like a table, acts like a table in the Query analyzer).
I have a Procedure which should return only 1 Record on selecting record according to Priority.
BEGIN DECLARE @Accounts nvarchar(MAX) SELECT @Accounts = ISNULL([map_user_modules].[Accounts], '') FROM [map_user_modules] WHERE [map_user_modules].[id_user] = 231 AND [map_user_modules].[id_module] = 5 IF ((@Accounts = '') OR (@Accounts = 'All')) SELECT @Accounts = null
BEGIN Select @@ROWCOUNT as Priority2 END IF @@ROWCOUNT = 1 BEGIN Return END
BEGIN Select @@ROWCOUNT as Priority3 END IF @@ROWCOUNT = 1 BEGIN Return END
BEGIN Select @@ROWCOUNT as Priority4 END IF @@ROWCOUNT = 1 BEGIN Return END
In the above statement Suppose we take a scenario where Select @@ROWCOUNT as Priority3 is executed, I get two tables returned, One is the Table returned by Select @@ROWCOUNT as Priority3 and the other is the Table returned by Select @@ROWCOUNT as Priority2 which has no Records. How can I eliminate the Empty table that returns no records.
I am trying to get the @@Identity from a table by using a stored procedure called by my asp.net website. I am using a datareader to do this but get an error as it tells me it cannot convert the returned value to getint. Here is my code. What should I be using instead of getint?
Dim myReader = cmd.ExecuteReader() While (myReader.Read()) intID = myReader.GetInt32(0) End While myReader.Close()
Initially, I have tried to use stored procedure. But I changed my mind and preferred to call sql query in codebase with command text. However, it stills tries to find initially-called stored procedure (which is neither called or exists).I think that it is related caching. But I tried it with different browsers it did not work.What might be the reason?
I am working in Asp.net 4.5. I need to create a grid as like below, I am struggling to make the merging cells and make it as multi header row by combining all the cells...
Is there any sample to make gridview like this.... I need to do this on codebehind. I browse through the internet and found couple of sample but those are not having the header like i posted. I am little confused about making full header as merged cells....
I want to create a listing view in which the record will be in this format(basically one record based on other, what mvc approach i should follow) .Basically i am using linq to sql and i have module and features in the same table with module being identified by is module =true tag . basically i am looking for suitable mvc approach. i could create a codebehind html table and rendered it here but that not i am looking for.
My table Module1 Module1Feature Module1Feaure2 Module1Feature3