Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Author: ErcanOPAK

ASP.Net WebForms / C#

Add blank item at top of dropdownlist

- 10.06.18 - ErcanOPAK comment on Add blank item at top of dropdownlist

drpList.Items.Insert(0, new ListItem(String.Empty, String.Empty)); drpList.SelectedIndex = 0;

Read More
SQL

Capitalize words in SQL (Display data first letter uppercase rest lowercase)

- 08.06.18 | 22.11.19 - ErcanOPAK comment on Capitalize words in SQL (Display data first letter uppercase rest lowercase)

SELECT UPPER(LEFT(colname,1)) + LOWER(RIGHT(colname, LEN(colname) – 1)) FROM tablename

Read More
ASP.Net WebForms / SQL

How to solve “TableAdapter can’t see stored procedure returned fields when using temp table” problem

- 06.06.18 | 22.11.19 - ErcanOPAK comment on How to solve “TableAdapter can’t see stored procedure returned fields when using temp table” problem

Add these lines to the beginning of your stored procedure. The statement is never executed, but for some reason it gets the job done. I really don’t know how and why 🙂 IF 1=0 BEGIN SET FMTONLY OFF END

Read More
ASP.Net WebForms / HTML / JavaScript

Get and Use TextBox Values with Javascript

- 04.06.18 | 22.11.19 - ErcanOPAK comment on Get and Use TextBox Values with Javascript

Here is the example code to get and use TextBox Values with Javascript:

Read More
SQL

Get the row number “x” from SQL

- 04.06.18 | 22.11.19 - ErcanOPAK comment on Get the row number “x” from SQL

WITH Records AS (SELECT ROW_NUMBER() OVER(ORDER BY ID_of_your_SQLTable) AS ‘ROW’, * FROM yourSQLTable) SELECT * FROM Records WHERE ROW = X –You can change X with the number you wanna get (For Example ROW = 5 will bring the 5th record)

Read More
ASP.Net WebForms

Add RowNumber to Gridview

- 04.06.18 | 22.11.19 - ErcanOPAK comment on Add RowNumber to Gridview

<Columns> <asp:TemplateField HeaderText=”RowNumber”> <ItemTemplate> <%# Container.DataItemIndex + 1 %> </ItemTemplate> </asp:TemplateField> … </Columns>

Read More
SQL

Add Default Value in SQL Server

- 03.06.18 | 03.06.18 - ErcanOPAK comment on Add Default Value in SQL Server

If there is no default value for the column then you can use this query: ALTER TABLE MyTable ADD CONSTRAINT df_MyTable_MyColumn DEFAULT 0 FOR MyColumn

Read More
SQL

Search text in all stored procedures in SQL Server

- 03.06.18 | 22.11.19 - ErcanOPAK comment on Search text in all stored procedures in SQL Server

SELECT name FROM sys.procedures WHERE Object_definition(object_id) LIKE ‘%search_parameter%’

Read More
ASP.Net WebForms / C#

Hide GridView Column on server-side

- 03.06.18 | 22.11.19 - ErcanOPAK comment on Hide GridView Column on server-side

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[index].Visible = false; }

Read More
SQL

Find numbers with more than two decimal places in SQL

- 02.06.18 | 24.03.26 - ErcanOPAK comment on Find numbers with more than two decimal places in SQL

The Problem: In financial databases, you often expect values to have exactly two decimal places (e.g., $10.50). However, due to bulk imports or rounding errors, “hidden” decimals like 10.50001 can creep into your tables. These tiny fractions can cause massive discrepancies in your total sums and reports. The Smart Solution: Instead of slow string parsing, […]

Read More
Reportviewer

How to change ReportViewer Date Format

- 02.06.18 | 30.08.20 - ErcanOPAK comment on How to change ReportViewer Date Format

=Format(Fields!Date,Value,”dd.MM.yyyy”)

Read More
SQL

How to return only the Date from a SQL Server DateTime datatype

- 02.06.18 | 30.08.20 - ErcanOPAK comment on How to return only the Date from a SQL Server DateTime datatype

–You can change GETDATE() with the date you want to use SELECT CONVERT(date, GETDATE())

Read More
SQL

What does COALESCE do in SQL?

- 02.06.18 | 30.08.20 - ErcanOPAK comment on What does COALESCE do in SQL?

In SQL Server (Transact-SQL), the COALESCE function returns the first non-null expression in the list. If all expressions evaluate to null, then the COALESCE function will return null. SELECT COALESCE(NULL, NULL, ‘ErcanOPAK.com’, NULL, ‘blog.ErcanOPAK.com’); Result: ‘ErcanOPAK.com’ SELECT COALESCE(NULL, ‘ErcanOPAK.com’, ‘blog.ErcanOPAK.com’); Result: ‘ErcanOPAK.com’ SELECT COALESCE(NULL, NULL, 1, 2, 3, NULL, 4); Result: 1

Read More
SQL

How to find records based on CAPITAL and small letters in SQL Query?

- 01.06.18 | 30.08.20 - ErcanOPAK comment on How to find records based on CAPITAL and small letters in SQL Query?

SELECT * FROM SQLTABLE WHERE SUBSTRING(TableColumn, 1, 1) = ‘x’ COLLATE SQL_Latin1_General_CP1_CS_AS

Read More
C#

Fire Combobox SelectedIndexChanged with button code-behind

- 27.05.18 | 30.08.20 - ErcanOPAK comment on Fire Combobox SelectedIndexChanged with button code-behind

myComboBox_SelectedIndexChanged(myComboBox, new EventArgs()); // or (null, null)

Read More
SQL

Get a Tree view with SQL Query

- 27.05.18 | 07.06.22 - ErcanOPAK comment on Get a Tree view with SQL Query

First of all, I must thank to Maulik Dhorajia for his great post. That post saved me a lot. That’s the @Company table we will use: And here is the SQL Query we need to use: — Working Example ;WITH CTECompany AS ( SELECT EmpID, ParentID, PersonName , 0 AS HLevel, CAST(RIGHT(REPLICATE(‘_’,5) + CONVERT(VARCHAR(20),EmpID),20) AS […]

Read More
SQL

Database stuck in “Restoring” state

- 19.05.18 | 30.08.20 - ErcanOPAK comment on Database stuck in “Restoring” state

You can use this command: RESTORE DATABASE <database name> WITH RECOVERY

Read More
Page 69 of 69
« Previous 1 … 64 65 66 67 68 69

Posts navigation

Newer posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (447)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com