Tag Archives: .net

Dynamically Populating Dropdownlists

Had to do this today, took a few minutes of google searching

In order to dynamically populate a drop down list use the following logic:

SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand(query, connection);
SqlDataReader reader = command.ExecuteReader();
lstAppointmentType.DataSource = reader;
lstAppointmentType.DataTextField = “STUFF1”;
lstAppointmentType.DataValueField = “STUFF2”;

Easy stuff once you see it done. Note the column with [] around it is shown so you know to not include the []s when you add to the list.


An error occurred in the Microsoft .NET Framework while trying to load assembly

I received this error after deployment of a new Sql CLR function:

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65545. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly ‘sqlclr, Version=, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A)
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)

I found the following solution that seems to work:

Turn on the Trustworthy flag on the database you are deploying to using:


After that the clr assembly should have no problem running.


Ajax Modal Popup and the Field Validators

In one of my web application projects I wanted to create some modal popups that would collect user input and validate. I ran into an error using required field validators and regular expression validators.

The modal popup would show as normal and if the validators would trigger on bad input. Once a validator was triggered, if the user cancelled the modal popup they would no longer be able to activate any controls on the page.


Always put your validation controls in a validation group, this will prevent a few headaches you may run into. If you have multiple modal popup forms, put each forms validation controls in their own validation groups.