Error: String or Binary Data Would Be Truncated.
Desc:
Generally this error occurs when we are trying to inser/update large value in SQL server table that are not fit into columns lenght of table.
In one scenario i experienced the following scenario:
I had the one enum like below:
public enum MyEnum
{ First = 101, Second=102, Sixth=103)
now I was using this enum like MyEnum.First and assigning to the one variable
But when i was trying to insert that entity in database using LINQ i was getting the above error:
After doing debugging, I've to do following changes
var myvar = (int) MyEnum.First;
The above statement will return the 101,
that's it for now.
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Friday, May 14, 2010
object reference not set to an instance of an object C#
Error: object reference not set to an instance of an object
C# developer usually getting the above error, I'd suggeste first check where you are using Trim(), Substring(), Length(), ToUpper(), ToLower() function with string variables in your codind.
To Resolve:
if(!String.IsNullOrEmpty(userFirstName))
{
-- your userFirstName assignment code here
}
C# developer usually getting the above error, I'd suggeste first check where you are using Trim(), Substring(), Length(), ToUpper(), ToLower() function with string variables in your codind.
To Resolve:
if(!String.IsNullOrEmpty(userFirstName))
{
-- your userFirstName assignment code here
}
Wednesday, November 4, 2009
asyncronyes method invocation
http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
http://www.codeproject.com/KB/cs/AsyncMethodInvocation.aspx
http://www.codeproject.com/KB/cs/AsyncMethodInvocation.aspx
Labels:
C#
Sunday, November 2, 2008
.Net- ordered Hashtable
.Net 2.0 introduce "OrderedDictionary" in order to store sorted (key,object) pair value.
Here is the sample code in [C#]
using System.Collections.Specialized;
OrderedDictionary objOrderedDictionary = new OrderedDictionary();
objOrderedDictionary.Add("1", "first value");
objOrderedDictionary.Add("5", "second value");
objOrderedDictionary.Add("8", "third value");
objOrderedDictionary.Add("12", "fourth value");
//set enumerator
IDictionaryEnumerator enumerator;
enumerator = odServiceAmount.GetEnumerator();
while (enumerator.MoveNext())
{
string sKey = enumerator.Key.ToString().Trim();
string sValue = enumerator.Value.ToString().Trim();
}
Here is the sample code in [C#]
using System.Collections.Specialized;
OrderedDictionary objOrderedDictionary = new OrderedDictionary();
objOrderedDictionary.Add("1", "first value");
objOrderedDictionary.Add("5", "second value");
objOrderedDictionary.Add("8", "third value");
objOrderedDictionary.Add("12", "fourth value");
//set enumerator
IDictionaryEnumerator enumerator;
enumerator = odServiceAmount.GetEnumerator();
while (enumerator.MoveNext())
{
string sKey = enumerator.Key.ToString().Trim();
string sValue = enumerator.Value.ToString().Trim();
}
Subscribe to:
Posts (Atom)