Uncategorized

How to insert data in Sql database in C# with ADO.NET and return the identity column

With the help of ADO.NET in C# we can build a connection with any SQL database and perform data transactions. To perform the transaction the first step would be to get connected to a database. The following syntax will help to initialize a instance : using (SqlConnection connection = new SqlConnection(“Your connection strings”)) {} Now

How to insert data in Sql database in C# with ADO.NET and return the identity column Read More »

Insert data in a table in SQL

Following is the syntax for insert statements in SQL : INSERT INTO TableName(Column1,Column2……)VALUES(Value1,Value2…..) For Example we want to insert data in a table named People with the following columns : Following will be the insert query for inserting a record inside the table : Insert into People(PersonID,LastName,FirstName,Address,City) Values (1,’TestLastName’,’TestFirstName’,’TestAddress’,’TestCity’) This insert statement will insert a

Insert data in a table in SQL Read More »

Initialize Dictionary in C#

Following is the syntax for declaring a dictionary in C# : Dictionary<int,string> NewDictionary = new Dictionary<int,string>(); Now elements can be added in this list using function : NewDictionary.Add(1,“Name1”); NewDictionary.Add(2,“Name2”); Here 1 and 2 represents unique keys for vaules ‘Name1’ and ‘Name2’. The key is a unique value and same keys cannot exist in a dictionary.

Initialize Dictionary in C# Read More »