Tuesday, August 12, 2014

Strange Entity Error

I've been struggling with a strange Entity error in a new project that I've started. Here's the error:

 Method not found: 'System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher
 System.Data.Entity.Infrastructure.Interception.DbDispatchers.get_Connection()'.  

I played with removing items from the context, I removed items from the web.config, all with the same results. I couldn't find anybody that had successfully fixed the error.

On a lark, I removed the Entity Framework package from all projects in my solution and re-added them. Lo and behold, the error went away. I had read somewhere that this error could happen due to different versions of Entity being in the same solution but I had verified that they were all 6.1.1. Something must have become corrupted. Hope this helps someone else in the future.

Thursday, January 17, 2013

Utah Code Camp

Time to get ready for Utah Code Camp. It's going to be on March 23rd this year.

http://www.utahcodecamp.com/

If you're at all interested in becoming a better programmer, you need to be at this event.

Responsive Design

I want to learn the basics of Responsive Design. Anybody have good resources or suggestions?

Friday, January 11, 2013

I Like it LESS

I know I am late to the game but I like LESS. LESS is a dynamic stylesheet language. It makes CSS a whole lot smarter and easier to use. I won't go into all the specifics of it but LESS has made my CSS work so much better. With its ability to use mixins (functions) and variables makes CSS much more modular and reusable.

I'd recommend any web developer to take a look at LESS or the similar SASS.

Here's some things I use LESS for:
  • Reusable variables for color and other attributes
  • A mixin that properly handles the CSS to round corners for all browsers
  • A mixin that will handle the different browsers to get a gradient background
  • Nested styling
  • darken and lighten functions to get borders and gradients a certain percentage difference from a base color
  • Applying the attributes of an existing CSS class to another CSS class
There are two ways to get LESS to work: client-side compilation or server-side. The client-side compilation will download the LESS syntax and use JavaScript  to compile the syntax to a dynamically loaded stylesheet. This is probably the best way to do it while you're learning and figuring things out.

The server-side can be done two ways: on-the-fly or compilation. Both options are enabled by the dotLESS framework. On-the-fly uses an HTTP handler to convert the syntax on the server as it is requested by on the client. The compilation method is a "manual" process of telling dotless compiler to actually create a CSS file that you can then reference in your page.

Tuesday, July 10, 2012

VB6 DLL Failed to Load on Windows x64

I ran into a problem today that I struggled with for a couple of hours. I just had my machine upgraded from a Windows XP x86 (32 bit) to a Windows 7 x64 machine. We have some legacy custom applications that require a VB6 dll to be registered. Everytime I ran the regsrv32 command on the DLL to register it, I got the below error:


The module "MyVB6.dll" failed to load.

Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.

The specified module could not be found.

I found posts that talk about making sure I run the command with adminstrator rights but it didn't help. I finally found the below URL:

http://social.msdn.microsoft.com/Forums/en-US/sbappdev/thread/91cf3127-70fe-4726-8a27-31b8964430c5/

It says that I need to make sure that the DLL does not sit in the System32 folder like we did on WinXP. Because the DLL is a 32 bit DLL, you need to use the 32 bit version of regsvr32 and that is in the SysWOW64. I even tried to run the command from SysWOW64 but leave the DLL in System32 and still got the same error. The DLL must sit in the SysWOW64 folder and be registered by the regsvr32.exe in the SysWOW64 folder.

Tuesday, March 27, 2012

Getting Rid of Some SQL Cursors

I had a need to find a way to take a single column result set and put it into a single varchar variable. I did not want to go through the hassle or the overhead of doing a cursor for this. With a little Googling, I found the below article:

http://stackoverflow.com/questions/822615/what-is-the-best-way-to-collapse-the-rows-of-a-select-into-a-string

It shows a very nice way of solving my problem :

 DECLARE @A VARCHAR(max)
SET @A = ''
SELECT @A = @A + ISNULL(mt.ColA, '') + ', '
FROM dbo.MyTable AS mt
ORDER BY mt.ColA
SET @A = SUBSTRING(@A, 1, LEN(@A) - 2)
SELECT @A

I thought this was a pretty nice way to do what I was doing but then I thought of how we are constantly having to do cursors to generate files and realized that we could use this method to generate a file without using a cursor. The below code will add a line at a time to the variable and then the variable can be written to file.

 DECLARE @A VARCHAR(max) 
SET @A = '' 
SELECT @A = @A + ISNULL(mt.ColA, '') + ',' + ISNULL(mt.ColB, '') + CHAR(10) 
FROM dbo.MyTable AS mt 
ORDER BY mt.ColA
SELECT @A 
--Write @A to a file

Using the above method reduces considerably the code required to generate a file and makes it a lot easier to read. Look over it and let me know if you have any comments or recommendations.

Update: Found an issue with the above method. We were using this at work with a process that would work sometimes and not in at other times. After a bunch of playing and searching, I found the below queries:
  • http://blog.sqlauthority.com/2009/09/29/sql-server-interesting-observation-execution-plan-and-results-of-aggregate-concatenation-queries/
  • http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/
The first link essentially says that using the order by statement may cause unexpected results inconsistently.  Meaning that it will work one time but may not the next.

The second link gives the alternative by using a FOR XML PATH query hint. Very helpful

Tuesday, October 04, 2011

Javascript Fiddling

I found a neat web development tool this morning. It's called jsFiddle. It allows you to play with HTML, javascript, and CSS on the fly. It also lets you save your "fiddles" for later. They also give each of your fiddles a unique URL so you can share them. Great for posting on forums and blogs. I'm very excited for this. Check out my very cool and complex fiddle:

http://jsfiddle.net/codyschouten/gSp8M/

Tuesday, September 06, 2011

Linked Server "String data, length mismatch"

So I have a TSQL problem that has been bothering me for a few months now. I have a stored procedure that runs nightly via a SQL scheduled job. It has failed almost everynight since April. The stored procedure is still in test and has been in low priority so I have dabbled with figuring it out. Our DBAs really didn't have a clue what the problem was and I couldn't find an answer through search engines. The annoying part is that I could run it development just fine and it would only sporadically fail in the test environment for me. I finally got tired of it and started pulling the 2900+ lines of SQL. Here's the error that I got:

 OLE DB provider "SQLNCLI" for linked server "MySQLServer01" returned message "String data, length mismatch". 
Msg 7421, Level 16, State 2, Line 1
Cannot fetch the rowset from OLE DB provider "SQLNCLI" for linked server "MySQLServer01". .
So part of problem had to do with the fact that I was trying to join two bits of data from different servers. I had a join that tried to join a VARCHAR(30) field from one SQL Server to a NVARCHAR(MAX) field on another SQL Server. I know that this isn't going to be the fastest of JOINS but it was a requirement. Seems that there is a problem with joining the MAX to something in another server. Once I did a CONVERT(VARCHAR(30) to the VARCHAR(MAX) field, my query completed beautifully.

I'm not sure how I would resolve this issue if I had to really join VARCHAR(MAX) to VARCHAR(MAX), but I guess I'll handle that in the future if that day comes.

Thursday, August 18, 2011

Configuration Error System.Web.Extensions

Keep in mind that it has been a year or two since I've really played with creating and configuring websites via IIS. This is something I've done before but for some reason didn't recognize the error. I created a new website the other day and got a Configuration Error page that indicated that there was a problem with my setup that was not allowing the System.Web.Extensions namespace to load. A quick Google search revealed that I just needed to point the website's ASP.NET version should be 2.0.50727 instead of 1.1.4322.

Found the reminder here:

http://codeproject.wordpress.com/2008/01/17/configuration-error-systemwebconfigurationsystemwebextensionssectiongroup/


Thursday, July 28, 2011

Samsung Galaxy S2

This is the phone I really want:

CNET
PhoneArena

It really makes me happy thinking about it. It's been available since April but not in the U.S. Supposedly it will come out this August just ahead of the next iPhone announcement. A buddy at work bought the European version without contract for a lot of $$$. I can't justify doing that so I have until AT&T releases an American version with contract. I really should get over my tech porn problem.

Does anybody have this phone or seen others with it? Any impressions?

Fall 2011 Utah Code Camp

I'm planning on attending this fall's Utah Code Camp. It will be my first time attending but I have heard great things about it. Best part is that it's free.


http://utahcodecamp.com/

Wednesday, July 13, 2011

Query Trigger

I had a need recently to programattically query the triggers for a set of tables in my database. Here's the code that I used:

 SELECT DISTINCT
Tables.Name TableName
, Triggers.name TriggerName
, Triggers.crdate TriggerCreatedDate
, [Type] = CASE WHEN Triggers.xtype = 'TR' THEN 'SQL Trigger'
ELSE 'CLR Trigger'
END
, [Disabled] = OBJECTPROPERTY(OBJECT_ID(Triggers.name), 'ExecIsTriggerDisabled')
FROM
sysobjects Triggers
INNER JOIN sysobjects Tables
ON Triggers.parent_obj = Tables.id
AND Tables.xtype = 'U'
AND Tables.name = 'eperson'
LEFT JOIN syscomments Comments
ON Triggers.id = Comments.id
WHERE
Triggers.xtype IN ( 'TR', 'TA' )
ORDER BY
Tables.Name
, Triggers.name

Updated the above query to handle CLR triggers and to show if the trigger is disabled.

Regular Expression Editor/Helper

I’ve been using Expresso for a while now. It’s a handy tool for working with regular expressions. It has a library of regular expressions which is very helpful. The editor lets you try your regular expression against a whole bunch of test data so you can test your expression against all sorts of data. The tool has been key in my getting better at regular expressions. The best part is that it’s FREE. That just makes me feel so good.

http://www.ultrapico.com/Expresso.htm

Wow, Two Years

Wow, it's been two years since my last post. I think I've been recovering from my masters degree. I'm now feeling more inclined to get involved with the blog again, if anybody cares. I expect to start posting again. My current job has me doing more and more SQL projects so my posts will be more focused to that. Besides, we're still on .NET 3.5 and really need to get up-to-date on .NET 4.0 before I start posting .NET again. So embarrassing :D

Saturday, May 16, 2009

TSQL Between

I've been spending A LOT of my time in SQL logic lately. It's been pretty rare that I've opened up Visual Studio. Not necessarily pleased with this but one bonus is that I've learned a bit more about SQL. I just found out the other day that you there is a SQL operator called BETWEEN. It allows you select a range of values:

SELECT *
FROM MyTable
WHERE Year
BETWEEN 2000 AND 2009

I guess you're never too old to learn some new tricks.

School is Done

I just finished my last final for my masters degree! Next stop: Disneyland.

Master's Done!!

I just finished my last final for my masters degree. Hopefully I can start focusing on posting again to this blog.

Thursday, October 02, 2008

Website Printing

I found this cool website for helping you print website. It allows you to control everything that is to be printed. Give it a look.

http://www.printwhatyoulike.com

Tuesday, May 13, 2008

I'm So Stylish ....

I just found the coolest Firefox extension. It allows you to control the style of any website that is loaded into your Firefox browser. The extension has a community website that users submit their own styles so that others can share. For example, I really love using Gmail but I think their look-and-feel could have been done by a 10 year old. I grabbed a really nice looking user submitted file and voila .... I have a very nice looking email interface.

The style control can be used for all sorts of things:
-Remove annoying ads
-Change color scheme
-Adjust usability of website

One nice option is if you know CSS (Cascading Style Sheets), you can modify the style yourself. I have downloaded the user styles that I liked the best and then tweaked the style to be more what I like. It is amazing what you can do with this extension and CSS. I modified the Google search results page to keep the search box and button at the top of the page as I scroll. Now I can have Google return 50 search items and still be able to easily adjust my search criteria without scrolling anywhere.

I've been using it for a week and I am in love. Check out the Stylish extension website at: http://www.userstyles.org/

Tuesday, April 22, 2008

Encryption Question

I'm working on an encryption solution at work. We currently need to symmetrically encrypt a user's password and store it in a database field. I need to somehow securely store the symmetric encryption key so that no one can access it except this application. I can't store it in the code because tools like Reflector and can find it. Has anybody found a great way of doing this?