Friday, January 9, 2009

ADO.Net : Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

I'm a coder myself. I write software programs as part of my job. You may remember situations we run into sometimes in our daily work life. Can you recall a situation you're completely stuck not knowing how to fix things esp. when writing some kind of rocket science code. Just kidding!!

I see myself in those kind of situations lot of times trying to figure out best ways to implement piece of logic. I've a weakness for fancy and flamboyant code. But, that's NOT the approach. Simple and straight forward code always helps in achieving those "bilities" like maintainability, reliability and scalability. Just keep that always in your mind.

Coming to original point, I wish for a savior who can help me in solving those weird, hard to fix, some times simple and challenging errors. I spend time googling, reading books and online help to keep things going. From my own experiences, I decided to help folks around with what i found saving their valuable time.

Let's start with what i found today. I'm trying to fill an empty data table with data from a data reader. this is how i'm doing this ..

DataTable dt = new DataTable();
dt.Load(reader);
return dt;

But, this throws an error saying " Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

Error is understandable. But, reader contains data which is gathered from multiple tables. Importantly, i created empty data table which should be able to accept data the way it is. Whatever, point is if you happen to get same error. Try using DataTable.GetErrors() to know the exact error causing the trouble.

Or if you want to get away from this issue, try using a DataSet object and set EnableConstraints property to false. Now, Load the same data. I hope you don't see this issue.

Microsoft MSDN PDC event at chicago on Jan 13th 2009

Good news for the Microsoft developer community in Midwest region. Microsoft is bringing PDC MSDN Live developer conference to chicago on January 13th 2009. Great oppurtunity to know about Windows 7 operating system, Azure cloud computing, Silver light, .Net parallel programming, ASP.Net 4.0 road map, Visual Studio 2010, F# stuff and much more..

Interesting though, But, this is not a free event. Registration costs $99 which's worth and coming cheaper. There're goodies to be won at the end of event. Ofcourse, I make sure I attend this great event. Need to hone my skills!! huh..

You can get more info from here http://www.msdndevcon.com/Pages/Chicago.aspx

Thursday, January 1, 2009

Windows Communication Foundation(WCF) .Net Framework 3.5 certification

I recently completed Microsoft .Net Certification Exam(70-503) Windows Communication Foundation 3.5 application programming (WCF). I assume this is first standard certification exam for WCF from application development standpoint. I would like to share my thoughts & insights on exam, syllabus & preparation.


For a person with strong hands on experience in WCF application development I think this exam should be easy to get through. Exam focuses on your WCF application development skills only. Don't worry too much about internals of channels, listeners esp. building custom channels, overriding listeners behavior, composing custom bindings. Just know how they work and their overview.

For example, You should know the exact order of binding elements in a binding. Required and optional binding elements when building a custom binding. Transport binding element and encoding binding element are always required in any binding we build or use.

Spend as much time as you can on areas like security digital certificates, security tokens, security credentials and how they're utilized in WCF environment.

Get a good grasp on WCF transactions, sessions, instances and their inter dependencies. you'll find volley of questions on this topics in the exam.

Deploying WCF services, Hosting WCF services in different ways and consuming WCF services are another important areas to keep an eye.


Get a complete big picture of all standard bindings supported by WCF and their features. if you can prepare yourself a comparison chart it'll be easy to understand

For example: WS-Httpbinding doesn't support duplex communication. TCP binding supports duplex communication.

I've utilized four books for my preparation for the exam.

  1. Microsoft Windows Communication Foundation Step by Step by John Sharp
  2. Inside Windows Communication Foundation by Justin Smith
  3. MCTS .Net Framework 3.5 WCF application development (Exam:70-503) by Microsoft Press
  4. Learning WCF - Michele Leroux Bustamante O'Reilly publisher
I don't suggest you read all these books. But, after reading these books I can definitely say they atleast confuse you.

For instance, Learning WCF book says Default instance context mode for WCF services is PerSession mode whereas remaining books suggest PerCall mode as the default

From my personal opinion, you can prefer Microsoft Windows Communication Foundation Step by Step as a first book to read. This book attempts to present WCF concepts in a simple and precise manner not getting into overwhelmingly complex details.

For advanced users who intend to take WCF exam, Learning WCF is also a good read. Learning WCF is a kind of reference book. We'll have to tailor out necessary chapters for WCF exam.

Inside Windows Communication Foundation book is way beyond the expectations of beginners or intermediate WCF developers. Only advanced WCF developers can extract something useful for them. But, if you're interested in WCF extensibility then it's a good resource to begin with. But definitely this book gives you a very big picture in understanding whole WCF paradigm specifically channels, listeners, bindings, messages and all those core WCF concepts.

Finally, MCTS .Net Framework 3.5 WCF application development book can be utilized as last reference guide to see if we're aligned with WCF exam perspective. Just skim through the book to verify we covered everything ourself. I don't recommend this book as a serious reading for learning WCF. This book presents content in a passive, monotonous and disconnected way. It's kind of one time read for exam sake.

That's all I can think of for now. Any questions, send me an email or post your comments

To know more about the WCF certification visit this link

http://www.microsoft.com/learning/en/us/exams/70-503.mspx