Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Friday, March 30, 2012

How to trigger the update command of the SQLDataSource

Hi - I'm using .net2, and have a gridview, populated by a SQL Datasource (Edit, Insert, Delete, Select).

Like we all used to do with the datagrid, I've added text boxes into the footer, and a link button, which I'd like to use to fire the Update command.

How do I get the link button to trigger the update command?

Thanks, Mark

in you link button click event handler call

datasourceName.Update();

Hop this help

Monday, March 26, 2012

How to trace the records that have been related to the child table

The problem of mine is, I have a datagrid, Which displays data from a Employee(parent) table.

Now I want to delete some records based on the user selected checkbox,
only those records which has no related records in the EmployeeProject(child) can be deleted.
I want to know which are all the record that cannot be deleted?

How can I achieve this?

You need to find out the related records on the child tables by following the primary/foreign key relationships. In the future you can use theON DELETE CASCADE command, or similar, when you create a table, so it will delete all child records automatically. If you don't know the table relationships, I suggest you find out as much as possible about the structure you're working with before allowing data deletion.

|||

SELECT Employee.*,CASE WHEN EXISTS(SELECT * FROM EmployeeProject ep WHERE ep.EmployeeID=e.EmployeeID) THEN 0 ELSE 1 END AS Deletable

FROM Employee e

Then in your datagrid, make a button column that has a commandname of "Delete". Convert that column to a template field. Now databind the button's visible in the template field to Deletable. This isn't a perfect solution because changes can take place in the database from the time you generate the page until you get back the request to delete, but it handles the vast majority of cases. Just make sure you handle the case where you are requested to delete a record that either no longer exists (Most code will just silently fail anyhow), or is no longer deletable (Try/catch the attempt to delete, and on failure, re-databind the grid and toss up an error to the user).

|||

Sorry, didn't notice that you wanted checkboxes. Use the same query, just databind the checkbox'ed enabled property to the Deletable field.

how to trace the file activity???

Dear all,
It urgent, can anyone please tell me how to race
the activity which the user have done to the file. e.g.
When the user delete a record from the file, when the
user edit a record from the file and when the user add a
new record to a file from the EM.Please, help.. Thanks.
Regards
Sharon
.There are several ways. One is to add a trigger to every table you wish to
audit that keeps track of all this activity. Of coarse this doesn't help
for any activity that already happened. Another much easier way is to use a
3rd party product such as Log Explorer from www.lumigent.com to look at the
log files and see the history. Of coarse if you have already truncated the
logs you may not have the information.
Andrew J. Kelly
SQL Server MVP
"sharon" <anonymous@.discussions.microsoft.com> wrote in message
news:130a901c44390$4ac6a320$a601280a@.phx
.gbl...
> Dear all,
> It urgent, can anyone please tell me how to race
> the activity which the user have done to the file. e.g.
> When the user delete a record from the file, when the
> user edit a record from the file and when the user add a
> new record to a file from the EM.Please, help.. Thanks.
> Regards
> Sharon
>
> .
>sql

How to trace the database activity

Dear all,
It urgent, can anyone please tell me how to race
the activity which the user have done to the file. e.g.
When the user delete a record from the file, when the
user edit a record from the file and when the user add a
new record to a file from the EM.Please, help.. Thanks.
Regards
Sharon
Please don't post independently in multiple newsgroups. You can add the
other newsgroups in the "Newsgroups" section in the header and it will show
up in all those simultaneously as will the answers. See my reply in the
other newsgroup.

Andrew J. Kelly
SQL Server MVP
"sharon" <anonymous@.discussions.microsoft.com> wrote in message
news:1329601c44387$f1f0c2b0$a501280a@.phx.gbl...
> Dear all,
> It urgent, can anyone please tell me how to race
> the activity which the user have done to the file. e.g.
> When the user delete a record from the file, when the
> user edit a record from the file and when the user add a
> new record to a file from the EM.Please, help.. Thanks.
> Regards
> Sharon
>

Friday, March 23, 2012

how to tell when a database was lasted accessed by general users?

Hi,
In the Subject, by general users, I meant those users who did regular
database operations, like insert, update, delete, etc. rather than the users
who have special privileges to do database maintenance operations, like
backup. We need to clean up those databases that haven't been accessed for
quite a while. Right now, we back up all the databases.
Thanks in advance,
BingHi
AFAIK there is not an easy way without either prolonged profiling or
possibly enabling C2 auditing. Alternatively products like auditdb from
Lumigent http://www.lumigent.com/products/auditdb.html would be able to tell
you, and log readers like their log explorer
http://www.lumigent.com/products/le_sql.html would be show updates.
A maverick approach may be to make the database readonly and see who squeals
!!
John
"bing" wrote:

> Hi,
> In the Subject, by general users, I meant those users who did regular
> database operations, like insert, update, delete, etc. rather than the use
rs
> who have special privileges to do database maintenance operations, like
> backup. We need to clean up those databases that haven't been accessed fo
r
> quite a while. Right now, we back up all the databases.
> Thanks in advance,
> Bing

how to tell when a database was lasted accessed by general users?

Hi,
In the Subject, by general users, I meant those users who did regular
database operations, like insert, update, delete, etc. rather than the users
who have special privileges to do database maintenance operations, like
backup. We need to clean up those databases that haven't been accessed for
quite a while. Right now, we back up all the databases.
Thanks in advance,
Bing
Hi
AFAIK there is not an easy way without either prolonged profiling or
possibly enabling C2 auditing. Alternatively products like auditdb from
Lumigent http://www.lumigent.com/products/auditdb.html would be able to tell
you, and log readers like their log explorer
http://www.lumigent.com/products/le_sql.html would be show updates.
A maverick approach may be to make the database readonly and see who squeals!!
John
"bing" wrote:

> Hi,
> In the Subject, by general users, I meant those users who did regular
> database operations, like insert, update, delete, etc. rather than the users
> who have special privileges to do database maintenance operations, like
> backup. We need to clean up those databases that haven't been accessed for
> quite a while. Right now, we back up all the databases.
> Thanks in advance,
> Bing
sql

how to tell when a database was lasted accessed by general users?

Hi,
In the Subject, by general users, I meant those users who did regular
database operations, like insert, update, delete, etc. rather than the users
who have special privileges to do database maintenance operations, like
backup. We need to clean up those databases that haven't been accessed for
quite a while. Right now, we back up all the databases.
Thanks in advance,
BingHi
AFAIK there is not an easy way without either prolonged profiling or
possibly enabling C2 auditing. Alternatively products like auditdb from
Lumigent http://www.lumigent.com/products/auditdb.html would be able to tell
you, and log readers like their log explorer
http://www.lumigent.com/products/le_sql.html would be show updates.
A maverick approach may be to make the database readonly and see who squeals!!
John
"bing" wrote:
> Hi,
> In the Subject, by general users, I meant those users who did regular
> database operations, like insert, update, delete, etc. rather than the users
> who have special privileges to do database maintenance operations, like
> backup. We need to clean up those databases that haven't been accessed for
> quite a while. Right now, we back up all the databases.
> Thanks in advance,
> Bing

Friday, February 24, 2012

how to store a record before deleting it using triggers

hey ,
im new to SQL. i wanted to save a particular record before deleting it usin
g a delete trigger can anyone help me on this .. thnxIO you want to store the whole row and therefore the data you could
consider leaving the data in the table and marking the row as "deleted"
by flagging the row with a bit column as deleted. If you don=B4t want to
maintain the whole row you could do something like this:
CREATE Trigger DELTrg_SomeTable ON SomeTable
FOR DELETE
AS
BEGIN
INSERT INTO SOmeTable
SELECT * from Deleted
/*
Rather than using the asterix to Select the column and data I would
namer the columns you want to select and insert therefore lgiving you
the opputunity to fill in additional fields which are extended int he
archive (something like an audit data, who deleted what row from what
host, etc.)
*/
END
HTH, Jens Suessmeyer.

Sunday, February 19, 2012

How to stop replication of a database?

When trying to drop a test database I get an error can't delete because it
is being usefor replication. But in the replication monitor there is no
publisher. I removed it. How can I stop this db from being used for
replication and then drop it?
Thks for any help
RD
Hi,
To remove replication, you can use Disable Publishing and Distribution
Wizard in SQL Server Enterprise Manager.
The Disable Publishing and Distribution Wizard in enterprise manager is
written to handle
this situation, and will remove all the replication settings.
To get to the wizard:
- Right click on the Replication folder in the server tree (or any child
node of the Replication folder)
- Select Disable Publishing and Distribution
- Go ahead in clicking next in the Wizard
After the removal, you could try dropping your database
Thanks
Hari
SQL Server MVP
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>
|||Try sp_removedbreplication. See SQL Server Books Online for more
information. Also use sp_dboption to mark the database as not published, if
needed.
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>
|||Thanks to you both
RD
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>

How to stop replication of a database?

When trying to drop a test database I get an error can't delete because it
is being usefor replication. But in the replication monitor there is no
publisher. I removed it. How can I stop this db from being used for
replication and then drop it?
Thks for any help
RDHi,
To remove replication, you can use Disable Publishing and Distribution
Wizard in SQL Server Enterprise Manager.
The Disable Publishing and Distribution Wizard in enterprise manager is
written to handle
this situation, and will remove all the replication settings.
To get to the wizard:
- Right click on the Replication folder in the server tree (or any child
node of the Replication folder)
- Select Disable Publishing and Distribution
- Go ahead in clicking next in the Wizard
After the removal, you could try dropping your database
Thanks
Hari
SQL Server MVP
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>|||Try sp_removedbreplication. See SQL Server Books Online for more
information. Also use sp_dboption to mark the database as not published, if
needed.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>|||Thanks to you both
RD
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>

How to stop replication of a database?

When trying to drop a test database I get an error can't delete because it
is being usefor replication. But in the replication monitor there is no
publisher. I removed it. How can I stop this db from being used for
replication and then drop it?
Thks for any help
RDHi,
To remove replication, you can use Disable Publishing and Distribution
Wizard in SQL Server Enterprise Manager.
The Disable Publishing and Distribution Wizard in enterprise manager is
written to handle
this situation, and will remove all the replication settings.
To get to the wizard:
- Right click on the Replication folder in the server tree (or any child
node of the Replication folder)
- Select Disable Publishing and Distribution
- Go ahead in clicking next in the Wizard
After the removal, you could try dropping your database
Thanks
Hari
SQL Server MVP
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>|||Try sp_removedbreplication. See SQL Server Books Online for more
information. Also use sp_dboption to mark the database as not published, if
needed.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>|||Thanks to you both
RD
"Bob" <bdufournosp@.sgiims.com> wrote in message
news:%23LRchFGmFHA.1948@.TK2MSFTNGP12.phx.gbl...
> When trying to drop a test database I get an error can't delete because it
> is being usefor replication. But in the replication monitor there is no
> publisher. I removed it. How can I stop this db from being used for
> replication and then drop it?
> Thks for any help
> RD
>