Toad World® Forums

Guid.ToString Exception when running query between nvarchar and guid


Was scrolling a results set to the right when this exception came up and the grid came up with a big red “X” instead of showing data.

Format String can be only “D”, “d”, “N”, “n”, “P”, “p”, “B”, “b”, “X” or “x”.
Stack Trace:
at System.Guid.ToString(String format, IFormatProvider provider)
at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
at Quest.Toad.Grid.GridSettings.IntegerToDisplay(Object obj)
at Quest.Toad.SqlServer.SqlServerConnection.customDisplayTextInteger(Object sender, CustomDisplayTextEventArgs e)
at DevExpress.XtraEditors.Repository.RepositoryItem.RaiseCustomDisplayText(CustomDisplayTextEventArgs e)
at DevExpress.XtraEditors.Repository.RepositoryItemTextEdit.RaiseCustomDisplayText(CustomDisplayTextEventArgs e)
at DevExpress.XtraEditors.Repository.RepositoryItem.RaiseCustomDisplayText(FormatInfo format, Object editValue, String displayText)
at DevExpress.XtraEditors.Repository.RepositoryItem.GetDisplayText(FormatInfo format, Object editValue)
at DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo.GetDisplayText()
at DevExpress.XtraEditors.ViewInfo.TextEditViewInfo.GetDisplayText()
at DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo.OnEditValueChanged()
at DevExpress.XtraEditors.ViewInfo.BaseEditViewInfo.set_EditValue(Object value)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.UpdateCellEditViewInfo(GridCellInfo cell, Point mousePos, Boolean canFastRecalculate, Boolean calc)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CreateCellEditViewInfo(GridCellInfo cell, Boolean calc, Boolean allowCache)
at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.RequestCellEditViewInfo(GridCellInfo cell)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRowCell(GridViewDrawArgs e, GridCellInfo ci)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRegularRow(GridViewDrawArgs e, GridDataRowInfo ri)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRow(GridViewDrawArgs e, GridRowInfo ri)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawRows(GridViewDrawArgs e)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.DrawContents(GridViewDrawArgs e)
at DevExpress.XtraGrid.Views.Grid.Drawing.GridPainter.Draw(ViewDrawArgs ee)
at DevExpress.XtraGrid.Views.Base.BaseView.Draw(GraphicsCache e)
at DevExpress.XtraGrid.GridControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.XtraEditors.Container.EditorContainer.WndProc(Message& m)
at DevExpress.XtraGrid.GridControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The issue is related to the join between two tables where one table stores a guid as nvarchar(200), the other is still a UNIQUEIDENTIFIER datatype:
test.dbo.[Invoice Header] ih
INNER JOIN test.dbo.OrderDetails md
ON ih.LegacyReferenceText = md.MemberOrderID

Selecting * from either table on its own does not produce this error, but selecting data from one or the other does cause the issue.

I’ve e-mailed to Alexander a small database that has shows the issue. In this database I removed almost all the columns from the [Invoice Header] table to show that it happens even when there aren’t a lot of columns in the table.

If you add back to that table enough columns so that when you run the query you will need to scroll to the right to see the 2nd table’s columns, then you WILL see results, and get the exception when you scroll to the right.

If you run the query as is, you’ll notice the error immediately.



Hi Darren,
Thanks a lot for the backup! Promise, Ill keep it safe!

I’ve restored this on my 2012 server and could not reproduce from three different client machines with 229 Beta build (two W7 64bit and one W8 64bit). I’ve scrolled to left-right-down-up with a lot of attempts and clicking to each cell from left to the right.
Did you have a chance to take a look on another client machine?

Also, what is your server version (so I can try to dig in this direction)?



This is on a SQL Server 2008 R2 Enterprise instance. I’ll try to repro it now on another build of Toad.


Maybe this was a memory related issue, because now I can no longer reproduce.

An hour ago it was happening 100% of the time, now it’s not happening at all, on any instance.