It depends on Data-Type of your Column["
code"] of Table["
server"].
If Data-Type is Int/Numeric, then below code should work.
cmd.CommandText = "SELECT name FROM server WHERE code="+TextBox1.Text;
In case Data-Type is Varchar / Non-Numeric then try as below.
cmd.CommandText = "SELECT name FROM server WHERE code='" + TextBox1.Text + "'";
However, I don't recommend in-line queries to you. Instead use parametrized query. Because plain inline query is an invite for SQL-Injection.
string sqlConnectString = "YourConnectionString";
string sqlSelect = "SELECT name FROM server WHERE code= @CodeValue";
SqlConnection sqlConnection = new SqlConnection(sqlConnectString);
SqlCommand sqlCommand = new SqlCommand(sqlSelect, sqlConnection);
sqlCommand.Parameters.Add("@CodeValue", System.Data.SqlDbType.Int);
sqlCommand.Parameters["@CodeValue"].Value = TextBox1.Text;
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCommand);
DataTable sqlDt = new DataTable();
sqlDa.Fill(sqlDt);