You need to actually pass in a parameter:
command.CommandText = "SELECT * FROM CUSTOMER WHERE Id = @Id;";
command.Parameters.Add("@Id", SqlDbType.Int).Value = Id;
var reader = command.ExecuteReader();
More Related Contents:
- How to make an algorithm to get all column names from across tables that relations with their primary key in SQL Server and C#?
- C# Sql Textbox Select
- How to execute a stored procedure within C# program
- How to get the connection String from a database
- Conversion of a datetime2 data type to a datetime data type results out-of-range value
- Entity framework very slow to load for first time after every compilation
- How do I return multiple result sets with SqlCommand?
- Visual Studio: ContextSwitchDeadlock
- Query extremely slow in code but fast in SSMS
- How to connect to SQL server database from a Windows 10 UWP app
- ExecuteNonQuery for SELECT sql statement returning no rows
- SqlDataSourceEnumerator.Instance.GetDataSources() does not locate local SQL server 2008 instance
- SQLException : String or binary data would be truncated
- SSIS Task for inconsistent column count import?
- Entity-framework code is slow when using Include() many times
- Creating a SQL Server table from a C# datatable
- SQL: Update a row and returning a column value with 1 query
- Is there an Entity Framework 7 Database-First POCO Generator?
- Invalid column name sql error
- Retrieve image from database in asp.net
- Entity Framework | Sequence contains more than one matching element
- When is it better to store flags as a bitmask rather than using an associative table?
- Keyword Not Supported: Metadata
- Why is EF generating SQL queries with unnecessary null-checks?
- Know when to retry or fail when calling SQL Server from C#?
- What’s the best way to bulk database inserts from c#?
- How to insert data into SQL Server
- SQL Server Database Change Listener C#
- Should the order of LINQ query clauses affect Entity Framework performance?
- How do I connect to a SQL database from C#?