Fórmulas e Cenas

Object Reference Not Set to an Instance of an Object

  Home  |   Contact  |   Syndication    |   Login
  45 Posts | 0 Stories | 16 Comments | 0 Trackbacks





select * FROM information_schema.tables where table_schema='YourSchema' ......

When you are inserting into a table using entity framework, on rare occasions you might get the following error: {System.Data.OptimisticConc... Store update, insert, or delete statement affected an unexpected number of rows (0) This happened to me because of an "instead of INSERT" trigger that was active on the page. It turns out that EF does not go well with triggers, because it fails to get the inserted ID. For me, the solution was to change the trigger so that the last executed code ......

Restoring a database can be a pain in the ass, specially when you need to find some point in time where the data went wrong.This is the best way i know how:RESTORE DATABASE MY_TARGET_DATABASE FROM DISK = 'path_to_backup.bak' WITH NORECOVERY, replaceGORESTORE LOG MY_TARGET_DATABASE FROM DISK = 'mytransaction_log1.trn' WITH NORECOVERYGORESTORE LOG MY_TARGET_DATABASE FROM DISK = 'mytransaction_log2.trn' WITH NORECOVERYgoRESTORE LOG MY_TARGET_DATABASE FROM DISK = 'mytransaction_log3.trn' WITH NORECOVERYgoRESTORE ......

/* Processes that are blocking others */
select * from 
where spid in
	syslocks l
	inner join sysprocesses p on p.spid=l.spid
	p.dbid=5 -- Database ID
	and p.blocked<>0

/* Processes being blocked*/
	syslocks l
	inner join sysprocesses p on p.spid=l.spid
	and p.blocked<>0


Occasionally an application that I am working on throws the above error... After trying to fix my code for a bit, and not finding the problem I googled a bit and discovered that this error is caused by a windows service that must be running. So, if you ever encounter this error, you must turn on the 'Distributed Transaction Coordinator' in order to solve it. Hope this helps. Original source: http://geekswithblogs.net/n... ......

update n set n.fieldToUpdate=o.fieldToUp... from originaltable o inner join toTable n on n.id= o.id ......

 exec sp_changeobjectowner 'ObjectName', 'newOwner'


More info at: http://msdn.microsoft.com/en-us/library/Aa259618

DBCC CHECKIDENT (yourtable, reseed, 0) Enjoy :) ......

I think it's common knowledge that timeouts can be set on connection strings to ensure that a certain connection doesnt say open for more than SSS seconds. What is not so common knowledge is the fact that on a transaction every single command has its own timeout value and if exceded it can bring down the entire transaction. So when using transactions take in mind that you can set the connection timeout to 20 minutes, but if a single command that takes a few extra seconds can timeout. To prevent this ......