Category: SQL-SERVER

ConnectionStrings – (Localdb)\v11.0

[cc] <add name=”SimpleSecurityConnection1″ connectionString=”Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-RefApp-20131021102513.mdf;Initial Catalog=aspnet-RefApp-20131021102513;Integrated Security=True” providerName=”System.Data.SqlClient” /> [/cc]   Favorite

Read more

ExecuteNonQuery / ExecuteScalar

Namespaces: System.Data; System.Xml; System.Configuration; // Clear out any test records from previous test executions. using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings[“DB_NAME”].ConnectionString)) { connection.Open(); string _mediaId = string.Empty; string _title = “Title”; using (System.Data.SqlClient.SqlCommand cmd = connection.CreateCommand() as System.Data.SqlClient.SqlCommand) { System.Data.SqlClient.SqlCommand cmd1 = new System.Data.SqlClient.SqlCommand(sql, connection); cmd1.CommandType = CommandType.Text; using (System.Data.SqlClient.SqlDataReader reader = cmd1.ExecuteReader()) { while (reader.Read()) […]

Read more