Geeks With Blogs
Fórmulas e Cenas Object Reference Not Set to an Instance of an Object Geral
Entity Framework, Insert Fail
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 ......

Posted On Tuesday, January 22, 2013 10:35 AM

How to restore a database using multiple transation log files (sql server 2000)
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 ......

Posted On Monday, October 22, 2012 11:18 AM

How to select distinct rows from a DataTable
DataView view = new DataView(table);DataTable distinctValues = view.ToTable(true, "Column1", "Column2" ...); Source: ......

Posted On Tuesday, October 2, 2012 11:53 AM

How to: Use like '%text%moretext%' using LinqToEntities

Simple and direct:

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

Posted On Wednesday, April 18, 2012 8:52 AM

string.Format input string was not in a correct format
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 ......

Posted On Monday, December 19, 2011 9:46 AM

How to handle ""Maximum request length exceeded" exception
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 ......

Posted On Tuesday, September 20, 2011 6:36 AM

How to execute a javascript function every time an updatepanel executes an async postback

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


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




Posted On Tuesday, September 20, 2011 4:57 AM

How to find locks in sql server 2000
/* 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


Posted On Thursday, June 16, 2011 11:03 AM

How to: Upload a file using FTP
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 = ......

Posted On Thursday, October 7, 2010 11:31 AM

How to: Download a file using FTP
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]; ......

Posted On Thursday, October 7, 2010 11:24 AM

Copyright © Sglima | Powered by: | Join free