BugNET

Open source issue tracking & project management

Forums

HomeHomeSupportSupportInstalling BugN...Installing BugN...Conversion failed when converting from a character string to uniqueidentifierConversion failed when converting from a character string to uniqueidentifier
Previous
 
Next
New Post
3/2/2010 8:40 PM
 

I just learned about BugNET and I am testing it out. I've installed it using a SQL 2008 server. It appears to work fine to the point where I have setup my first project, but if I attempt to go to any project pages (ie Milestones, Categories, Assignees etc) I get the the error below.

I ran SQL Profiler and found an example statement where this occurs:

exec sp_executesql N'SELECT * FROM BugNet_IssuesView WHERE ProjectId=@projectId AND Disabled=0 AND IssueId IN (SELECT IssueId FROM BugNet_Issues WHERE 1=1 AND IssueMilestoneId IS NULL AND IssueAssignedUserId = @p1) ORDER BY IssueId DESC',N'@projectId int,@p1 nvarchar(32)',@projectId=1,@p1=N'357daa0ea9ef4b71a8dee526576177ea'

As you can see it appears that the problem is with converting an nvarchar to a uniqueidentifier. Assuming this isn't an issue in SQL 2005, is there some setting in SQL I can make to avoid this error? I tried changing the Compatability Level of the database to 2005 but that didn't work.

Conversion failed when converting from a character string to uniqueidentifier.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting from a character string to uniqueidentifier.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): Conversion failed when converting from a character string to uniqueidentifier.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +212
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +245
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2811
   System.Data.SqlClient.SqlDataReader.HasMoreRows() +290
   System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +297
   BugNET.DataAccessLayer.SqlDataProvider.TGenerateIssueListFromReader(SqlDataReader returnData, List`1& issueList) +74
   BugNET.DataAccessLayer.SqlDataProvider.TExecuteReaderCmd(SqlCommand sqlCmd, TGenerateListFromReader`1 gcfr, List`1& List) +161
   BugNET.DataAccessLayer.SqlDataProvider.PerformQuery(Int32 projectId, List`1 queryClauses) +1274
   BugNET.Issues.IssueList.BindIssues() +1912
   BugNET.Issues.IssueList.Page_Load(Object sender, EventArgs e) +1163
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   BugNET.UserInterfaceLayer.BasePage.OnLoad(EventArgs e) +21
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428


Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016

 
New Post
3/17/2010 12:45 PM
 

UPDATE: I installed this on my dev box that is running SQL 2008 Developer and it works just fine. I completely removed BugNet from my server which is running SQL 2008 Standard. I backed up the db from my dev box and restored the db on my server. I then copied over the entire application and changed only the connectionstring in the web.config. I still get the error!

It seems evident that the Developer edition will implicitly convert a string to a uniqueidentifier but the Standard edition will not. I can't help but think this is not a bug, but some setting in SQL.

Does this throw a flag for anybody? Any thoughts would be appreciated.

Tim

 
New Post
3/17/2010 3:23 PM
 

UPDATE 2: I've concluded that the issue is not related to SQL and that it must have something to do with this app running in different environments. Here is what I have learned. With my dev box and production server running identical code and databases, with the exception of the connectionstrings in the web.config file, I ran the sql profiler against each database while clicking on just about any link on the Project Summary page (any link to the issues/issuelist.aspx file). For some reason, in my dev environment the code builds a different WHERE clause. Here is what is being executed on the SQL servers.

On my dev box:
exec sp_executesql N'SELECT * FROM BugNet_IssuesView WHERE ProjectId=@projectId AND Disabled=0 AND IssueId IN (SELECT IssueId FROM BugNet_Issues WHERE 1=1 AND IssueCategoryId = @p0 AND IssueStatusId <> @p1) ORDER BY IssueId DESC',N'@projectId int,@p0 int,@p1 int',@projectId=1,@p0=1,@p1=5

And on my production box:
exec sp_executesql N'SELECT * FROM BugNet_IssuesView WHERE ProjectId=@projectId AND Disabled=0 AND IssueId IN (SELECT IssueId FROM BugNet_Issues WHERE 1=1 AND IssueCategoryId = @p0 AND IssueAssignedUserId = @p1 AND IssueStatusId <> @p2) ORDER BY IssueId DESC',N'@projectId int,@p0 int,@p1 nvarchar(32),@p2 int',@projectId=1,@p0=1,@p1=N'8744be237b424a95aec967338c1e69f6',@p2=5

Note that on the production box parameter named IssueAssignedUserId is being added with a value that appears to be a uniqueidentifier minus the dashes. Please note that in my test project nothing has been assigned to any user. Even more peculier is that the uniqueidentifier "8744be237b424a95aec967338c1e69f6" (with or without dashes) appears nowhere in my database. I suspect it should be the primary key to one of my users, but it isn't. So the question is, where is this coming from? And why does it only happen on my production server?

Tim

 
New Post
3/18/2010 10:41 PM
 

Eureka! I figured out the issue! The problem was that BugNET checks for a querystring key that is the letter u, and if it exists, it adds the IssueAssignedUserId parameter to the WHERE clause, but when it checks the querystring it uses Request.Params, which also includes name/value pairs from form data as well as cookies. It just happens that another site that uses the same domain that I am running BugNET on stores a cookie with the key u. Because BugNET is using Request.Params it is picking up this value from the cookie of another site within the same domain. I changed a local copy of the source code to use Request.Querystring instead of Request.Params, rebuilt and deployed and everything is perfect!

I'd like to suggest this change be made to the published code to avoid this edge case.

Thanks.

 
New Post
3/19/2010 6:29 AM
 

Let me know where in the code you made this change and I will update it.

Thanks.


Davin Dubeau

follow us on twitter facebook users group google plus
 
Previous
 
Next
HomeHomeSupportSupportInstalling BugN...Installing BugN...Conversion failed when converting from a character string to uniqueidentifierConversion failed when converting from a character string to uniqueidentifier


Forum Policy

These Discussion Forums are dedicated to the discussion of the BugNET issue tracker.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:
1. No Advertising.
2. No Flaming or Trolling.
3. No Profanity, Racism, or Prejudice.
4. Site Moderators have the final word on approving/removing a thread or post or comment.
5. English language posting only, please.