Based on this link: http://msdn.microsoft.com/en-us/library/windowsazure/ee336243.aspx
I am trying this code to connect to an Azure SQL database and insert the line:
// The values being assigned to the StringBuilder members are set previously/not shown SqlConnectionStringBuilder connStringBuilder = new SqlConnectionStringBuilder(); connStringBuilder.DataSource = dataSource; connStringBuilder.InitialCatalog = databaseName; connStringBuilder.Encrypt = true; connStringBuilder.TrustServerCertificate = false; connStringBuilder.UserID = userName; connStringBuilder.Password = password; using (SqlConnection conn = new SqlConnection(connStringBuilder.ToString())) { using (SqlCommand command = conn.CreateCommand()) { conn.Open(); command.CommandText = "INSERT INTO T1 (col1, col2) values (1, 'string 1'), (2, 'string 2'), (3, 'string 3')"; int rowsAdded = command.ExecuteNonQuery(); } conn.Close(); }
An attempt, that is, SqlConnectionStringBuilder, SqlConnection , and SqlCommand not recognized / not allowed. Do I need to install a separate ADO.NET package for this, or what is the deal?
UPDATE
By adding System.Data.dll to my project links (on my machine, from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5 ), I could recognize / enable these classes, but still get compile-time errors, namely:
Error 1 The base class or interface "System.ComponentModel.Component" in the assembly "System, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089, which is referenced by the type" System.Data.Common.DbConnection ", cannot be resolved c: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5 \ System.Data.dll
and
Error 2 The base class or interface "System.ComponentModel.Component" in the assembly "System, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089, which is referenced by the type" System.Data.Common.DbCommand "cannot be resolved c: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5 \ System.Data.dll
UPDATE 2
Adding SQL.Data as a reference allowed to resolve various types, however, another problem did not allow compilation of the application, namely:
Cannot find type System.SystemException in module mscorlib.dll
Removing SQL.Data from the links fixed this problem.