SSMS viewInfo error with no database list shown

PROBLEM

Opened SSMS 2012 and got error viewInfo. Unable to see database list.
On Refresh databases same error.

SOLUTION

For me it was to do a restore back 2 days

BACKGROUND

Others have had this.

Sysinternal Tools and filters to “Process Name is ssms.exe” and “Path contains AppData\Local\Temp”

It seemed to not be finding an Addin.

https://connect.microsoft.com/SQLServer/feedback/details/573771/value-cannot-be-null

https://github.com/TaoK/PoorMansTSqlFormatter/issues/48

T-SQL unable to CAST text to a number – Byte order mark – Dodgy character at start

Scenario

Imported some data from Excel in form “156 x 54 x 16mm”. Parsed the text to get the 156. However this would not convert to a numeric.

Error converting data type nvarchar to numeric

After some exploration I discovered that the cursor required to steps through before the number. So a character was there that SQL Server could not display. To find this I used:

SELECT Code, UNICODE(LEFT(DimensionsTextImport, 1)) AS UnicodeTest FROM Product.<tablename>

And discovered text which would not convert had Unicode 65279

Solution

Create a new column and fill this with the data from the first column after a CASE statement.

UPDATE Product.Dimensions
SET DimensionsText = CASE
WHEN UNICODE(LEFT(DimensionsTextImport, 1)) = 65279 THEN SUBSTRING(DimensionsTextImport, 2, 50)
ELSE DimensionsTextImport END

With reference to:

http://stackoverflow.com/questions/6441208/unable-to-replace-char63-by-sql-query

http://www.fileformat.info/info/unicode/char/feff/index.htm

http://en.wikipedia.org/wiki/Byte_Order_Mark

 

 

Continue Statement (Visual Basic) (T-SQL) “Control-of-Flow Language”

My SQL 70-461 study reminded me about the T-SQL CONTINUE statement to cause execution to jump back to the beginning of the loop. Re. Querying Microsoft SQL Server 2012 – MS Press – p 479

http://msdn.microsoft.com/en-us/library/ms178642.aspx – SQL Server

I keep needing this in VB.Net and for some reason it is missing from my VB.Net vocabulary. Not any longer…

http://msdn.microsoft.com/en-us/library/801hyx6f(v=vs.100).aspx  – VB.Net

Continue transfers control immediately to the next iteration of a loop.

Cannot use adobe reader to view pdf in your browser. Reader will now exit. Please exit your browser and try again.

PROBLEM:

  • Windows 7 64-bit
  • Internet Explorer 9
  • Adobe Reader 8.3.1

When opening a pdf in i.e

“Cannot use adobe reader to view pdf in your browser. Reader will now exit. Please exit your browser and try again.”

With reference to:

http://forums.adobe.com/thread/511010

Uninstall version 8.3.1 and install latest. For me this was 11.x.x

Crystal Reports Error: The request could not be submitted for background processing

If there is a database picture this may need to be re-imported

Why Entity Framework is releasing on NuGet only – One Unicorn

Hmm

http://blog.oneunicorn.com/2012/02/11/why-entity-framework-is-releasing-on-nuget-only/

Might work with deployment.

Seems to encourage copying EntityFramework each and every time you copy the files across.

Outlook Expand Group fails. Cannot perform the requested operation.

Problem

Outlook Expand Group fails. Cannot perform the requested operation. The command selected is not valid for this recipient. The Operation failed.

Solution

Outlook > Contacts > Open Group > Update Now

One or more members of this contact group cannot be found…

 

 

An error occurred generating a bootstrapper: Unable to begin updating resource for bin\Debug\app.publish\setup.exe with error 80070002 TESTPUBLISH

ERROR

An error occurred generating a bootstrapper: Unable to begin updating resource for bin\Debug\app.publish\setup.exe with error 80070002 TESTPUBLISH

A SOLUTION to get it to work

Untick the Prerequisites button

See also:

http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/9ab9b88b-a57b-4945-9f94-e48a82ad5d8c

 

Crystal Reports – Invalid Argument provided. Failed to open a rowset. Error in File Invalid argument for database

At first thought it ran OK in Crystal not when called from program.

Then checked that it ran from the program on the Crystal developer machine OK.

So runs OK on developer’s machine not on particular user’s machines.

Hence error with ODBC. Changed developer machine ODBC to use from SQLNCLI to SQL Server Native Client 10.0 i.e. SQLNCLI10 and then went to report and “Set Location” for the newest table, the report then worked on all machines

Entity Framework Code First connection to a database

Connection String

  <connectionStrings>
    <add name="<my>Entities"
connectionString="Data Source=<servername>;
initial catalog=<dbname>;
integrated security=True;
multipleactiveresultsets=True;
App=EntityFramework;"
providerName="System.Data.SQLClient" />
  </connectionStrings>

Database Class

Imports System.Data.Entity

Public Class myDatabase
    Inherits Entity.DbContext

    Property Products() As DbSet(Of Products)
    Property Logs() As DbSet(Of myLog)

    Sub New()
        MyBase.New("EFIEntities")
    End Sub

    Protected Overrides Sub OnModelCreating(ByVal modelBuilder As DbModelBuilder)

        modelBuilder.Entity(Of Products).Map(Sub(mc) mc.ToTable("Product.Products"))

        modelBuilder.Entity(Of myLog).Map(Sub(mc)mc.ToTable("dbo.Logs"))

        modelBuilder.Entity(Of IHead)().Property(Function(f) f.OrderCreated).
                   HasColumnName("ih_date")

        modelBuilder.Entity(Of Film).Ignore(Function(f) f.ColumnNotInDB)

	'For Composite Key
	modelBuilder.Entity(Of RouteCardOpsProduct).
		HasKey(Function(f) New With {f.ProductID, f.OpOrder})

        modelBuilder.Entity(Of ComponentCF).Property(Function(f) f.ProductID)
		.HasDatabaseGeneratedOption(ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None)

'Creating Foreign Keys with thanks Julie Lerman
Note: this is tricky and easily broken with the wrong syntax.
Instead before doing the below consider a LINQ statement which would use navigation properties which work surprisingly well
Dim result = From c In context.Customers Where c.ID = 14 Select New With {c, c.Quotes}  'Anonymous type
To return this as a customer do this:
        Function FindCustomerIncludeQuotes(CustomerIDValue As Integer) As Customer
            Dim query = (From c In context.Customers
                         Where c.ID = CustomerIDValue
                         Select New With {c, c.Quotes}).FirstOrDefault

            Dim result = query.c
            result.Quotes = query.Quotes
            Return result
        End Function

'http://msdn.microsoft.com/en-us/data/gg194009
'http://msdn.microsoft.com/en-us/data/hh134698.aspx
	modelBuilder.Entity(Of Post)().HasRequired(Function(p) p.Blog).WithMany(Function(b) b.Posts).HasForeignKey(Function(p) p.FKBlogId)

	modelBuilder.Entity(Of Post)().HasMany(Function(p) p.Tags).WithMany(Function(t) t.Posts).Map(Sub(mc)
				mc.ToTable("PostJoinTag")
				mc.MapLeftKey("PostId")
				mc.MapRightKey("TagId")
			End Sub)

     End Sub End Class

Classes

Public Class Products
    <key> Public Property ID As Integer
    Public Property Code As String
End Class

Public Class RouteCardOps
	'Composite key do mapping in OnModelCreating. Column may not work yet in EF v4.x
	<key> Property ID As Integer
	<key> Property OpOrder As Integer
	Property OpCode As String

	Overridable Property Product As Product
End Class

Public Class PadCost
    <key, DatabaseGenerated(DatabaseGeneratedOption.None)> Property PadID As Integer
    <DatabaseGenerated(DatabaseGeneratedOption.Computed)>Property Total SMV As Decimal
End Class

Public Class Blog
 	<key> Property ID As Integer
	Property Title As String
End Class

Public Class Posts
	<key> Property ID As Integer
	Property Title As String
	Property BlogID As Integer

	Overidable Property Blog As Blog
End Class

Program

Module Module1
Sub Main()

Dim db As New myDatabase

Dim resultProduct = From a In db.Products
Where a.Code = "abc"
Select a

Dim result = From a In db.Logs Select a Take 10

Console.WriteLine(String.Concat("Log ID: ", result.First.ID))
Console.WriteLine(String.Concat("Product ID: ", resultProduct.First.ID))
Console.WriteLine()
Console.WriteLine("Press a key to continue/end")
Console.ReadKey()

'To Execute SQL directly against the database
context.Database.ExecuteSqlCommand("DELETE FROM Product.Products WHERE ID = ", 1)

'Then you may need to instantiate a new copy or clear an existing copy use context.Set(Of <entity>)
contextCF.Products = contextCF.Set(Of Products)()
End Sub

End Module

Windows Forms

http://msdn.microsoft.com/en-us/data/jj682076.aspx

Imports System.Data.Entity

now
	context.MyEntity.Load()
	MyBindingSource.DataSource = context.MyEntity.Local.ToBindingList

was
    'context.Currency.Load()
    DbExtensions.Load(context.Currency)
    Me.CurrencyBindingSource.DataSource = DbExtensions.ToBindingList(context.Currency.Local)

Errors and solutions:

Error Unable to load the specified metadata resource
Solution: For code first the metadata=res is unnecessary. Just use an ordinary connection string as above.

Error: ‘Load’ is not a member of System.Data.Entity.DbSet(Of …)
Solution:
Use Imports System.Data.Entity
Also ensure there is a reference to EntityFramework in the project. Especially if this is an N-Tier solution

Error: With Inherited class even it is the parent class that is being collected. Then get Invalid column name ‘Discriminator’
Solution Add <NotMapped> to child class
modelBuilder.Ignore<classname>();

Error: INSERT does not insert key if this is not an IDENTITY
Solution: Add attribute as <key, DatabaseGenerated(DatabaseGeneratedOption.None)>
Or modelBuilder.Entity<Address>().Property(p => p.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

Error: After a delete using context.Database.ExecuteSQLCommand(“DELETE…”) the context still have copies of the entities in any DBSet which needs to be cleared
Solution: context.Products = context.Set(Of Products)()

Error: The type initializer for ‘System.Data.Entity.Internal.AppConfig’ threw an exception
Solution:
If Entity Framework is installed by NuGet then you should not have a problem. However after a version update, or manual changes you may get this fault. One problem may be that in the App.Config file the section name may be missing as below:

<configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
      <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>

Error:
The Entity Framework provider type ‘System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer’ registered in the application config file for the ADO.NET provider with invariant name ‘System.Data.SqlClient’ could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

Solution:
Add reference to EntityFramework.SqlServer, which may have not been installed via NuGet for some reason
Or if new then it may not have been built properly, so try building project again.
See link in error or: http://msdn.microsoft.com/en-us/data/jj730568

End