[SOLVED] Relation lines not showing up in dataset designer when adding new tableadapter

Question:
I added a new table in my MS SQL database, and set up relationships between the new table and an existing table. I went to Visual Studio’s dataset designer (one I had already started) and added the new table, but I’m not seeing the relation line as I would expect. What gives?

Answer:
Go to your project’s settings and make sure there isn’t a new connection string made when you tried to add the new table. This happened to me and took me a while to realize VS created a new connection string for me when I tried adding a new tableadapter using Windows Integrated Security (My original connection string has plain username and password)

[SOLVED] Winforms .NET Application Slow to Load When There is no Internet Connection

Background Info

Here is a rather strange behavior I saw when I deployed a .NET application onto a PC: It takes about a whole minute for my main form to show up! The machine is running Windows 7 on a 2.6G duo core CPU with 2GB RAM with no other applications running.

I’ve deployed the same software onto different PCs of same hardware and OS configuration, and the same software would load within seconds on PCs with internet connection.

I use Devexpress’s Winforms component for my applications, so I thought maybe it has something to do with checking for component license via the internet, but it couldn’t be. I paid for the components already!

Solution

Turns out it has something to do with Microsoft .NET’s authenticode signature checking, and without internet connection, you literally just have to wait for all the behind-the-scene process to timeout.

To disable signature authentication, open up your [application].exe.config file in your Program Files directory and add the following element under <configuration>:

      <runtime>
              <generatePublisherEvidence enabled=”false”/>
      </runtime>

NOTE: You may need to give WRITE permission to your application’s config file to make the edit.

NOTE: You will not see this slow loading problem if you are not using a signed 3rd party (in this case it’s Devexpress) component in your application.

You can read more about it here:

https://www.devexpress.com/Support/Center/Question/Details/Q363966
http://blogs.technet.com/b/markrussinovich/archive/2009/05/26/3244913.aspx
https://msdn.microsoft.com/en-us/library/bb629393(v=vs.110).aspx

Handling “Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.”

I came across a dreaded exception when using tableadapter to update a datarow:

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

I pulled my hair out on this one – read up on concurrency violation and what could cause this exception. MSDN and stackoverflow users would tell you it’s due to a datarow being “detached” from the dataset, or somewhere in code you are doing an update to dataset and your copy of datarow is not the current one.

Whatever, not going to pretend I understand it. Not going to pretend I don’t have a hole in my code somewhere. I just want to update my record Goddammit!

So, here is what you do… go to your dataset designer, right click on the property of your tableadapter and expend on the UpdateCommand property. You’ll want to change the SQL query text’s WHERE cause to only match the primary key ONLY.

For example, the auto-generated update command may be:

UPDATE table
SET field1=value1, field2=value2, etc.
WHERE id=@original_id, field1=@original_field1, field2=@originalfield2…

All you got to do is change it to update row with a row ID:

UPDATE table
SET field1=value1, field2=value2, etc.
WHERE id=@original_id

Problem solved! No more concurrency violation exception, but this doesn’t mean you shouldn’t look for places in your code where concurrent updates may take place and put in some safety measures.