string sql = "select * from e where empno= ' " + datagridview.currentrow.cells(0).value.tostring() + " ' ";
Why is the value of empno
between single quotes even though the empno
is defined as an integer?
string sql = "select * from e where empno= ' " + datagridview.currentrow.cells(0).value.tostring() + " ' ";
Why is the value of empno
between single quotes even though the empno
is defined as an integer?
May i make a suggestion to make your code easier to read. When working with string formatting, use interpolation rather than the '+' operator.
String interpolation provides a more readable and convenient syntax to create formatted string.
Example :
// Replace this line
string sql = "select * from e where empno= ' " + datagridview.currentrow.cells(0).value.tostring() + " ' ";
// By this one
string sql = $"select * from e where empno='{datagridview.currentrow.cells(0).value.tostring()}'";
Documentation : String Interpolation