Monday, September 9, 2024

How do I check the status of a SQL Server transaction?

 You can check the status of running transactions using this query:

SELECT session_id, transaction_id, database_id, transaction_begin_time, transaction_state, transaction_status

FROM sys.dm_tran_active_transactions;

This query gives you information about active transactions in SQL Server.

How do I list all tables in a specific database?

 You can use the following query to list all tables in the current database:

SELECT TABLE_NAME 

FROM INFORMATION_SCHEMA.TABLES

WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG = 'YourDatabaseName';

This query returns the names of all base tables in the specified database.


How can I check the size of a specific database in SQL Server?

 You can check the size of a database using the following query:

EXEC sp_spaceused;

Or, for a specific database:

USE YourDatabaseName;

EXEC sp_spaceused;

This command returns the database size, reserved space, unallocated space, and more.

How do I find the SPID (Session Process ID) for a specific database in SQL Server?

 SELECT 

    es.session_id AS SPID, 

    es.login_name, 

    es.status, 

    es.host_name, 

    es.program_name, 

    es.database_id, 

    DB_NAME(es.database_id) AS database_name,

    ec.client_net_address,

    er.wait_type, 

    er.wait_time, 

    er.blocking_session_id

FROM sys.dm_exec_sessions es

LEFT JOIN sys.dm_exec_connections ec ON es.session_id = ec.session_id

LEFT JOIN sys.dm_exec_requests er ON es.session_id = er.session_id

WHERE es.database_id = DB_ID('YourDatabaseName');

------------------------------------------------------------------------------------

kill SSID

Monday, September 2, 2024

The breakpoint will not currently be hit. No symbols have been loaded for this document.

If you are getting this error breakpoint in view then there is some error in view or some property name is wrong. Then check and fix all lines. After correction it will work.

Thursday, August 29, 2024

An unhandled exception of type 'System.TypeInitializationException' occurred in System.ServiceModel.dll. Additional information: The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception.

 Common Causes:

  • Configuration Errors: Issues in your WCF configuration (e.g., app.config or web.config) could trigger this exception. Check that your configuration files are correctly set up, especially sections related to diagnostics and tracing.

  • Missing or Corrupt DLLs: If a required DLL (e.g., System.ServiceModel.dll) is missing or corrupt, the type initializer might fail. Ensure that all necessary assemblies are present and correctly referenced in your project.

  • Permissions Issues: The TraceUtility class may attempt to access system resources, such as event logs or trace files. If the application lacks the necessary permissions, it could cause this exception. Ensure your application has the appropriate permissions to access these resources.

Tuesday, July 30, 2024

An exception of type 'System.DllNotFoundException' occurred in System.Data.SQLite.dll but was not handled in user code Additional information: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

folders named X64 and X86 Copy "SQLite.Interop.dll" to both folders after creating them inside the release or debug folders. 

Deprecation Listener added for a 'DOMSubtreeModified' mutation event. Support for this event type has been removed, and this event will no longer be fired. See chromestatus com/feature/5083947249172480 for more information.

[Deprecation] Listener added for a 'DOMSubtreeModified' mutation event. Support for this event type has been removed, and this event will no longer be fired. See https://chromestatus.com/feature/5083947249172480 for more information. 

old code
 $('.lg-map-text').bind("DOMSubtreeModified", function () {

           if ($('.lg-map-text').text() != "") {

                var getHtml = $('.lg-map-text');

              var state = getHtml["0"].children[1].value;

               if (state != undefined) {

                    GetDescription(state);

                    $('html, body').animate({

                        scrollTop: $('.whitesec').offset().top

                    }, 800

            );

                }

           }

        });


new changes 

// Function to be called when the mutation is observed

function onMutation(mutationsList, observer) {

    // Iterate through all mutations

    for (let mutation of mutationsList) {

        // Check if the mutation is a change to the text content

        if (mutation.type === 'childList' || mutation.type === 'subtree') {

            // Check if the element has text content

            if ($('.lg-map-text').text() != "") {

                var getHtml = $('.lg-map-text');

                var state = getHtml[0].children[1].value;

                if (state != undefined) {

                    GetDescription(state);

                    $('html, body').animate({

                        scrollTop: $('.whitesec').offset().top

                    }, 800);

                }

            }

        }

    }

}


// Select the target node

var targetNode = document.querySelector('.lg-map-text');


// Create a new MutationObserver instance and pass the callback function

var observer = new MutationObserver(onMutation);


// Options for the observer (which mutations to observe)

var config = { childList: true, subtree: true };


// Start observing the target node for configured mutations

observer.observe(targetNode, config);


Sunday, July 28, 2024

differences between an abstract class and an interface in C#

 The main differences between an abstract class and an interface in C# are as follows:


1. **Instantiation**: An abstract class cannot be instantiated on its own, while an interface cannot be instantiated at all. Abstract classes are designed to be base classes that provide a common definition for derived classes, while interfaces define a contract that implementing classes must adhere to.


2. **Implementation**: An abstract class can have both abstract and non-abstract methods, allowing it to provide a partial implementation of its members. In contrast, an interface can only have method signatures without any implementation. Implementing classes must provide the implementation for all interface members.


3. **Inheritance**: A class can inherit from only one abstract class, but it can implement multiple interfaces. This allows for a form of multiple inheritance through interfaces, where a class can inherit behavior from multiple sources.


4. **Access Modifiers**: Abstract classes can have access modifiers (e.g., public, private, protected) that provide fine-grained control over their members. Interfaces, on the other hand, have public access by default and cannot specify different access modifiers for their members.


Here's an example to illustrate the difference:


```csharp

// Abstract class

public abstract class Animal

{

    public abstract void MakeSound();


    public void Sleep()

    {

        Console.WriteLine("Zzzz...");

    }

}


// Interface

public interface IJumpable

{

    void Jump();

}


// Derived class implementing an abstract class and an interface

public class Cat : Animal, IJumpable

{

    public override void MakeSound()

    {

        Console.WriteLine("Meow!");

    }


    public void Jump()

    {

        Console.WriteLine("Jumping high!");

    }

}


// Usage

public static void Main()

{

    Cat cat = new Cat();

    cat.MakeSound(); // Output: Meow!

    cat.Sleep(); // Output: Zzzz...

    cat.Jump(); // Output: Jumping high!

}

```


In the example above, the `Animal` class is an abstract class that provides a partial implementation of the `MakeSound` method and a non-abstract `Sleep` method. The `IJumpable` interface defines the `Jump` method. The `Cat` class inherits from the `Animal` class and implements the `IJumpable` interface, providing the necessary implementations for all the inherited members.


I hope this example helps clarify the difference between abstract classes and interfaces in C#. Let me know if you have any further questions!

Monday, June 3, 2024

What are Nullable types in C#?

Nullable types in C# allow value types to represent the normal range of values plus an additional null value. This is particularly useful when dealing with databases and other scenarios where a value might be undefined or missing.


### Key Points about Nullable Types


1. **Definition**:

   - Nullable types are instances of the `System.Nullable<T>` structure.

   - They can represent all the values of their underlying type `T`, plus an additional `null` value.


2. **Syntax**:

   - A nullable type is defined using the `?` syntax after the value type.

   ```csharp

   int? nullableInt = null;

   ```


3. **Properties and Methods**:

   - **HasValue**: Returns `true` if the variable contains a non-null value.

   - **Value**: Gets the value if `HasValue` is `true`; otherwise, it throws an `InvalidOperationException`.

   ```csharp

   if (nullableInt.HasValue)

   {

       int value = nullableInt.Value;

   }

   ```


4. **Null-Coalescing Operator**:

   - The `??` operator provides a default value when a nullable type has no value.

   ```csharp

   int value = nullableInt ?? 0; // value will be 0 if nullableInt is null

   ```


5. **Conversion**:

   - Nullable types can be implicitly converted from the underlying type.

   - Explicitly converting a nullable type to its underlying type requires checking for null first.

   ```csharp

   int? nullableInt = 5;

   int nonNullableInt = (int)nullableInt; // explicit conversion

   ```


### Example Code


```csharp

using System;


class Program

{

    static void Main()

    {

        // Declaration of a nullable int

        int? nullableInt = null;

        

        // Check if it has a value

        if (nullableInt.HasValue)

        {

            Console.WriteLine($"Value: {nullableInt.Value}");

        }

        else

        {

            Console.WriteLine("No value");

        }


        // Assign a value

        nullableInt = 10;


        // Use the null-coalescing operator

        int result = nullableInt ?? 0; // result will be 10

        Console.WriteLine($"Result: {result}");


        // Convert nullable to non-nullable

        if (nullableInt.HasValue)

        {

            int nonNullableInt = nullableInt.Value;

            Console.WriteLine($"Non-nullable int: {nonNullableInt}");

        }

    }

}

```


### Usage Scenarios

1. **Database Operations**: When retrieving data from a database, columns may contain null values.

2. **Optional Parameters**: When a method parameter is optional and can have no value.

3. **Data Validation**: Representing optional fields in data input forms.


Using nullable types ensures that your code can handle cases where a value might not be available, making it more robust and preventing potential runtime errors related to null values.