SQL to Update Rows in one Table from another Table

Some times we need to Update one table records based on another table value. One classical example is: Updating Product table quantity after placing an Order. Some developer Update Product Quantity by iterating through each order line item. But we can do this in a single query. Here in this article I will show you “How to Update Rows in one table from another table in SQL SERVER using a Single SQL Query“.

Read more ›

Posted in Database, SQL Server

SQL Server Error: String or binary data would be truncated

More often when we work on Bulk Load or Importing lot of Excel or CSV files into SQL Server from external sources then we received the error “String or binary data would be truncated the statement has been terminated“. The reason is simple. One or some of your column value length exceeded the column length declared in the table. So first we nee to produce the error.

Read more ›

Posted in Database, SQL Server

How to Replace Null Value in Asp.Net GridView BoundField Column in C# VB.Net

If the datasource of a GridView control contains NULL value then the GridView Cell render blank text. To make the information more meaningful we need to replace the NULL value with a meaningful word or a line. GridView BoundField column provides us a property named NullDisplayText, by which we can display any text instead of NULL.

Read more ›

Posted in .Net, Asp.net, C#, Gridview, VB.Net

How to Replace Null Value in Asp.Net GridView Template Field or Template Column in C# VB.Net

Null means nothing or meaningless. To make it meaningful we need to replace null value by an understandable word or a line. In C# and VB.Net we do it easily. But in GridView it’s a bit different. We can replace null value easily in GridView without calling any server side method or even replacing it in database query time. Here in this example I will show you “How we can replace NULL value in GridView TemplateField“.

Read more ›

Posted in .Net, Asp.net, C#, Gridview, VB.Net

How to Get DataKeyNames from Asp.Net Gridview selected Row in C# VB.Net

Sometimes we need to work on Asp.Net GridView Selected Row. When you click on Select link then SelectedIndexChanged method will fire. Within this method to uniquely identify a record we need to get the assigned DataKeyNames. Which will be a primary key of an object or entity. After getting the key value we can do anything depends on client requirement. So getting the DataKeyNames from Asp.Net GridView selected Row is a crucial operation. Here in this article I will explain how we can do this.

Read more ›

Posted in .Net, Asp.net, C#, Gridview, VB.Net

Bulk Insert CSV File into SQL Server Table using C# VB.Net

In many cases we need to insert CSV file into SQL Server Database table. Here in this article I will explain how one can “Insert CSV File Data into Sql Server Table using Bulk Insert“. But you can use Bulk Insert only if your DataBase server and Application server is same. Otherwise not.

Read more ›

Posted in .Net, C#, Database, SQL Server, VB.Net

SQLBulkCopy to Insert DataTable Rows at a Time into SQL Server Table using C# VB.Net

DataTable is a memory representation of SQL Server DataBase Table. We can direct Insert all records or rows of a DataTable into Sql Server Database Table at a time using SQL Bulk Copy. SQL Bulk Copy is a most efficient and preffered way to insert bulk rows at a time while the Database server is different from your application server. In this example I will prepare a DataTable first then Insert all Rows at a time to SQL Server Database using Bulk Copy instead of executing hundreds of thousands of insert Statements one by one.

Read more ›

Posted in .Net, C#, Database, SQL Server, VB.Net

JQuery to Call Asp.Net Ajax Page Methods with Parameter from Client Side in C# VB.Net

Calling server side method to server side is an easy job for developers. But sometimes we need to call server side methods from client side. Here in this article I will explain “How to Call Asp.Net Ajax Page Methods with Parameter from Client Side using JQuery“. First of all it’s not an easy job. To do that we have to use Asp.Net AJAX ScriptManager. Asp.Net AJAX ScriptManager has a property named EnablePageMethods and we need to set true to call server side method from client side using JQuery.

Read more ›

Posted in .Net, Ajax, Asp.net, C#, Client, JQuery, VB.Net

How to Send Asp.Net Gridview Content or Records or Rows or Data through Email using C# VB.Net

Asp.Net GridView Control is used for report presentation. Sometimes we need to send those reports to admin level through email. Using Asp.Net we can achieve this easily. Here in this article I will explain with example “How to Send Asp.Net Gridview Content or Records or Rows or Data through Email using C# VB.Net“. If you follow my steps hope you can also send GridView content through Email to the client.

Read more ›

Posted in .Net, Asp.net, C#, Gridview, VB.Net

How to Get Selected Row Values From a Gridview Control in Asp.Net C# VB.Net

For implementing more business logic some times we need to capture the data of GridView Selected Row. The event named SelectedIndexChanged provides us the easiest way to get selected row data. Because when user click on the Select Button the SelectedIndexChanged event will fire. Here in this article I will explain “How one can Get Selected Row Values From a Gridview Control in Asp.Net“. We will describe in both C# & VB.Net.

Read more ›

Posted in .Net, Asp.net, C#, Gridview, VB.Net