Fórmulas e Cenas

Object Reference Not Set to an Instance of an Object

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

News

Archives

Post Categories

Links

Geral

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 ......

DataView view = new DataView(table);DataTable distinctValues = view.ToTable(true, "Column1", "Column2" ...); Source: http://stackoverflow.com/qu... ......

Simple and direct:

myContainer.myEntity.Where("it.myField LIKE '%' + @searchTerm + '%'", new ObjectParameter("searchTerm", myQueryText));


If you have a "{" or "}" inside a string when using string.format you will get the error mentioned in the title. To fix this you must double the charater. Error Example: string teste = string.Format(" This is a {teste} {0} ", mystring); Correct Example: string teste = string.Format(" This is a {{teste}} {0} ", mystring);v ......

In global.asax: protected void Application_BeginRequest(Ob... sender, EventArgs e) { HttpRuntimeSection runTime = (HttpRuntimeSection)WebConf... //Approx 100 Kb(for page content) size has been deducted because the maxRequestLength proprty is the page size, not only the file upload size int maxRequestLength = (runTime.MaxRequestLength - 100) * 1024; //This code is used to check the request length of the page and if the request length is greater than ......

<script type="text/javascript" language="javascript">

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(refresh);

        function refresh() { //Your code here; }

</script>

 

Source


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

/* Processes being blocked*/
select 
	p.*
from 
	syslocks l
	inner join sysprocesses p on p.spid=l.spid
where 
	p.dbid=5
	and p.blocked<>0

 


FileInfo fileInf = new FileInfo("c:\myfile.txt"); FtpWebRequest reqFTP = (FtpWebRequest)FtpWebReques... Uri("ftp://myFTPSite/myfile... reqFTP.Credentials = new NetworkCredential("myUser",... "myFTPDomain"); reqFTP.KeepAlive = false; reqFTP.Method = WebRequestMethods.Ftp.Uploa... reqFTP.UseBinary = true; reqFTP.ContentLength = fileInf.Length; int buffLength = 2048; byte[] buff = new byte[buffLength]; int contentLen; FileStream fs = fileInf.OpenRead(); try { Stream strm = ......

FileStream outputStream = new FileStream("c:\myfilefolder... FtpWebRequest reqFTP = (FtpWebRequest)FtpWebReques... Uri("ftp://myFTPSite/file.t... reqFTP.Method = WebRequestMethods.Ftp.Downl... reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential("myUser",... FtpWebResponse response = (FtpWebResponse)reqFTP.GetR... Stream ftpStream = response.GetResponseStream(); int bufferSize = 2048; int readCount; byte[] buffer = new byte[bufferSize]; ......

Full Geral Archive