Skip to main content

Posts

What is the difference between ExecuteScalar, ExecuteReader and ExecuteNonQuery?

 ExecuteScalar is typically used when your query returns a single value. If it returns more, then the result is the first column of the first row. An example might be SELECT @@IDENTITY AS 'Identity'.  ExecuteReader is used for any result set with multiple rows/columns (e.g., SELECT col1, col2 from sometable).  ExecuteNonQuery is typically used for SQL statements without results (e.g., UPDATE, INSERT, etc.).

Create Database in SQL Server by Sql script

Put below script in sql Editor and change Database_Name to your Database name IF (NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE ('[' + name + ']' = 'Database_Name' OR name = 'Database_Name'))) Begin CREATE DATABASE [Database_Name] ALTER DATABASE Database_Name MODIFY FILE ( NAME = N'Database_Name' , SIZE = 3048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) ALTER DATABASE Database_Name MODIFY FILE ( NAME = N'Database_Name' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) End 

How to get Machine Name /Mac Address

How to get   Machine Name                     Get_Machin_Name = Environment.MachineName How to get   Mac Address             Dim mc As System.Management.ManagementClass             Dim mo As ManagementObject             Dim sMac As String = ""             mc = New ManagementClass("Win32_NetworkAdapterConfiguration")             Dim moc As ManagementObjectCollection = mc.GetInstances()             For Each mo In moc                 If mo.Item("IPEnabled") = True Then                     sMac = mo.Item("MacAddress").ToString()                     Exit For       ...