adsense

Sunday, October 31, 2021

use ADO.NET via Context.Database

The DbContext.Database property allows us to perform ADO.NET as sown below. 

 //Execute Reader

    using (var ctx= new DatabaseContext())
    using (var cmd= ctx.Database.GetDbConnection().CreateCommand())
    {
        cmd.CommandText = "SELECT * From Table1";
        cmd.Database.OpenConnection();
        using (var result = command.ExecuteReader())
        {
            // do something with result
        }
    } 


//Execute SP


using (var ctx= new DatabaseContext())
    using (var cmd= ctx.Database.GetDbConnection().CreateCommand())
    {
               cmd.CommandText = "dbo.someSP"
                _dataContext.Connection.Open()
                cmd.CommandType = CommandType.StoredProcedure

                Dim param As DbParameter = command.CreateParameter()
                param.DbType = DbType.Int16
                param.ParameterName = "@param1"
                param.Value = 'value1"
                cmd.Parameters.Add(param)

                param = cmd.CreateParameter()
                param.DbType = DbType.DateTime
                param.ParameterName = "@param2"
                param.Value = "value2"
                cmd.Parameters.Add(param)

                cmd.ExecuteNonQuery()
                _dataContext.Connection.Close()
        }
    } 


Cheers,

Samita

Sunday, October 17, 2021

find second DIV of the same class

If you need a CSS selector that can be used to find the 2nd DIV of  among several DIVs with the same class, CSS3 provides nth-of-type(n) selector as displayed below.

.row:nth-of-type(2) {


}


Cheers,

Samitha

Sunday, October 3, 2021

SQL sever 2014 compatibility issue when TLS 1.0 and TLS 1.1 is turned off

As there has been several vulnerabilities of  TLS 1.0 and TLS 1.1 it is turned off by default,  even though SQL latest releases supports this SQL 2014 need to be Upgraded SQL Server and the client components to  handle TLS 1..

This link further describes the issue and you will need to inset the relevant service pack for SQL 2014 (2014 SP2 and 2014 SP3.)

 

 

Cheers

Samitha